Fix apm-dubbo-2.7.x-plugin memory leak due to some Dubbo RpcExceptions. (#6432)

This commit is contained in:
osiriswd 2021-02-24 14:59:41 +08:00 committed by GitHub
parent 665a07cb0f
commit 8c3d1679e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -14,6 +14,7 @@ Release Notes.
* Fix ClassCastException of log4j gRPC reporter.
* Fix NPE when Kafka reporter activated.
* Enhance gRPC log appender to allow layout pattern.
* Fix apm-dubbo-2.7.x-plugin memory leak due to some Dubbo RpcExceptions.
#### OAP-Backend
* Allow user-defined `JAVA_OPTS` in the startup script.

View File

@ -24,6 +24,7 @@ import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Result;
import org.apache.dubbo.rpc.RpcContext;
import org.apache.dubbo.rpc.RpcException;
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
@ -109,8 +110,12 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor {
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
Result result = (Result) ret;
if (result != null && result.getException() != null) {
dealException(result.getException());
try {
if (result != null && result.getException() != null) {
dealException(result.getException());
}
} catch (RpcException e) {
dealException(e);
}
ContextManager.stopSpan();