Skip to content

Commit fbabc3d

Browse files
xiaqi1210xiaqi
andauthored
avoid ThreadPoolExecutor duplicate enhancement (#582)
Co-authored-by: xiaqi <xiaqi@51xf.cn>
1 parent d5ec438 commit fbabc3d

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ Callable {
147147
* Support to trace redisson lock
148148
* Upgrade netty-codec-http2 to 4.1.94.Final
149149
* Upgrade guava to 32.0.1
150+
* Fix issue with duplicate enhancement by ThreadPoolExecutor
150151

151152
#### Documentation
152153

apm-sniffer/bootstrap-plugins/jdk-threadpool-plugin/src/main/java/org/apache/skywalking/apm/plugin/AbstractThreadingPoolInterceptor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.skywalking.apm.plugin;
2020

2121
import org.apache.skywalking.apm.agent.core.context.ContextManager;
22+
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
2223
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
2324
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
2425
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
@@ -37,6 +38,11 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
3738

3839
Object argument = allArguments[0];
3940

41+
// Avoid duplicate enhancement, such as the case where it has already been enhanced by RunnableWrapper or CallableWrapper with toolkit.
42+
if (argument instanceof EnhancedInstance && ((EnhancedInstance) argument).getSkyWalkingDynamicField() instanceof ContextSnapshot) {
43+
return;
44+
}
45+
4046
Object wrappedObject = wrap(argument);
4147
if (wrappedObject != null) {
4248
allArguments[0] = wrappedObject;

0 commit comments

Comments
 (0)