avoid ThreadPoolExecutor duplicate enhancement (#582)

Co-authored-by: xiaqi <xiaqi@51xf.cn>
This commit is contained in:
xiaqi1210 2023-07-25 21:50:30 +08:00 committed by GitHub
parent d5ec43848f
commit fbabc3d3ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -147,6 +147,7 @@ Callable {
* Support to trace redisson lock
* Upgrade netty-codec-http2 to 4.1.94.Final
* Upgrade guava to 32.0.1
* Fix issue with duplicate enhancement by ThreadPoolExecutor
#### Documentation

View File

@ -19,6 +19,7 @@
package org.apache.skywalking.apm.plugin;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
@ -37,6 +38,11 @@ public abstract class AbstractThreadingPoolInterceptor implements InstanceMethod
Object argument = allArguments[0];
// Avoid duplicate enhancement, such as the case where it has already been enhanced by RunnableWrapper or CallableWrapper with toolkit.
if (argument instanceof EnhancedInstance && ((EnhancedInstance) argument).getSkyWalkingDynamicField() instanceof ContextSnapshot) {
return;
}
Object wrappedObject = wrap(argument);
if (wrappedObject != null) {
allArguments[0] = wrappedObject;