Skip to content

Commit

Permalink
avoid ThreadPoolExecutor duplicate enhancement (#582)
Browse files Browse the repository at this point in the history
Co-authored-by: xiaqi <[email protected]>
  • Loading branch information
xiaqi1210 and xiaqi authored Jul 25, 2023
1 parent d5ec438 commit fbabc3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,6 +38,11 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr

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;
Expand Down

0 comments on commit fbabc3d

Please sign in to comment.