This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.1 by this push:
     new e78a0b05e6 feat: fix oom (#11571)
e78a0b05e6 is described below

commit e78a0b05e60346e4d105d550abfa49cd2b0154b5
Author: aamingaa <[email protected]>
AuthorDate: Wed Feb 15 10:29:29 2023 +0800

    feat: fix oom (#11571)
---
 .../dubbo/rpc/proxy/AbstractProxyInvoker.java      | 27 +++++++++++-----------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/AbstractProxyInvoker.java
 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/AbstractProxyInvoker.java
index f9b6f0db82..871fe9672c 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/AbstractProxyInvoker.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/AbstractProxyInvoker.java
@@ -86,8 +86,8 @@ public abstract class AbstractProxyInvoker<T> implements 
Invoker<T> {
 
     @Override
     public Result invoke(Invocation invocation) throws RpcException {
+        ProfilerEntry originEntry = null;
         try {
-            ProfilerEntry originEntry = null;
             if (ProfilerSwitch.isEnableSimpleProfiler()) {
                 Object fromInvocation = invocation.get(Profiler.PROFILER_KEY);
                 if (fromInvocation instanceof ProfilerEntry) {
@@ -99,18 +99,6 @@ public abstract class AbstractProxyInvoker<T> implements 
Invoker<T> {
 
             Object value = doInvoke(proxy, invocation.getMethodName(), 
invocation.getParameterTypes(), invocation.getArguments());
 
-            if (ProfilerSwitch.isEnableSimpleProfiler()) {
-                Object fromInvocation = invocation.get(Profiler.PROFILER_KEY);
-                if (fromInvocation instanceof ProfilerEntry) {
-                    ProfilerEntry profiler = Profiler.release((ProfilerEntry) 
fromInvocation);
-                    invocation.put(Profiler.PROFILER_KEY, profiler);
-                }
-            }
-            Profiler.removeBizProfiler();
-            if (originEntry != null) {
-                Profiler.setToBizProfiler(originEntry);
-            }
-
             CompletableFuture<Object> future = wrapWithFuture(value, 
invocation);
             CompletableFuture<AppResponse> appResponseFuture = 
future.handle((obj, t) -> {
                 AppResponse result = new AppResponse(invocation);
@@ -133,7 +121,20 @@ public abstract class AbstractProxyInvoker<T> implements 
Invoker<T> {
             return AsyncRpcResult.newDefaultAsyncResult(null, 
e.getTargetException(), invocation);
         } catch (Throwable e) {
             throw new RpcException("Failed to invoke remote proxy method " + 
invocation.getMethodName() + " to " + getUrl() + ", cause: " + e.getMessage(), 
e);
+        } finally {
+            if (ProfilerSwitch.isEnableSimpleProfiler()) {
+                Object fromInvocation = invocation.get(Profiler.PROFILER_KEY);
+                if (fromInvocation instanceof ProfilerEntry) {
+                    ProfilerEntry profiler = Profiler.release((ProfilerEntry) 
fromInvocation);
+                    invocation.put(Profiler.PROFILER_KEY, profiler);
+                }
+            }
+            Profiler.removeBizProfiler();
+            if (originEntry != null) {
+                Profiler.setToBizProfiler(originEntry);
+            }
         }
+
     }
 
     private CompletableFuture<Object> wrapWithFuture(Object value, Invocation 
invocation) {

Reply via email to