Skip to content

Commit

Permalink
Merge branch 'apache:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
CzyerChen authored Apr 22, 2024
2 parents f78ff69 + 1a01047 commit 2dc8b4f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release Notes.
------------------

* Remove `idleCount` tag in Alibaba Druid meter plugin.
* Fix NPE in handleMethodException method of apm-jdk-threadpool-plugin.

All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/213?closed=1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,11 @@
public abstract class AbstractThreadingPoolInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
if (!ContextManager.isActive()) {
if (notToEnhance(allArguments)) {
return;
}

if (allArguments == null || allArguments.length < 1) {
return;
}

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);
Object wrappedObject = wrap(allArguments[0]);
if (wrappedObject != null) {
allArguments[0] = wrappedObject;
}
Expand All @@ -63,6 +52,25 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA

@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
if (notToEnhance(allArguments)) {
return;
}

ContextManager.activeSpan().log(t);
}

private boolean notToEnhance(Object[] allArguments) {
if (!ContextManager.isActive()) {
return true;
}

if (allArguments == null || allArguments.length < 1) {
return true;
}

Object argument = allArguments[0];

// Avoid duplicate enhancement, such as the case where it has already been enhanced by RunnableWrapper or CallableWrapper with toolkit.
return argument instanceof EnhancedInstance && ((EnhancedInstance) argument).getSkyWalkingDynamicField() instanceof ContextSnapshot;
}
}

0 comments on commit 2dc8b4f

Please sign in to comment.