File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed
arex-agent-bootstrap/src/main/java/io/arex/agent/bootstrap
arex-instrumentation/internal/arex-executors/src/main/java/io/arex/inst/executors Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1
1
package io .arex .agent .bootstrap .ctx ;
2
2
3
+ import io .arex .agent .bootstrap .internal .CallDepth ;
4
+
3
5
import java .util .HashMap ;
4
6
import java .util .Iterator ;
5
7
import java .util .Map ;
@@ -45,7 +47,11 @@ public void superRemove() {
45
47
}
46
48
47
49
public T copyValue () {
48
- return get ();
50
+ T value = get ();
51
+ if (value instanceof CallDepth ) {
52
+ return (T ) ((CallDepth ) value ).copy ();
53
+ }
54
+ return value ;
49
55
}
50
56
51
57
private static final ThreadLocal <WeakHashMap <ArexThreadLocal <Object >, ?>> holder =
@@ -76,7 +82,7 @@ public static class Transmitter {
76
82
77
83
public static Object capture () {
78
84
HashMap <ArexThreadLocal <Object >, Object > values = captureValues ();
79
- return values == null ? null : new Snapshot (captureValues () );
85
+ return values == null ? null : new Snapshot (values );
80
86
}
81
87
82
88
private static HashMap <ArexThreadLocal <Object >, Object > captureValues () {
Original file line number Diff line number Diff line change @@ -39,4 +39,10 @@ public int getAndIncrement() {
39
39
public int decrementAndGet () {
40
40
return --this .depth ;
41
41
}
42
+
43
+ public CallDepth copy () {
44
+ CallDepth copy = new CallDepth ();
45
+ copy .depth = this .depth ;
46
+ return copy ;
47
+ }
42
48
}
Original file line number Diff line number Diff line change 1
1
package io .arex .inst .executors ;
2
2
3
+ import io .arex .agent .bootstrap .TraceContextManager ;
3
4
import io .arex .agent .bootstrap .ctx .ArexThreadLocal ;
4
5
import io .arex .agent .bootstrap .internal .Cache ;
5
6
import io .arex .inst .extension .MethodInstrumentation ;
@@ -31,6 +32,9 @@ public List<MethodInstrumentation> methodAdvices() {
31
32
public static class ConstructorAdvice {
32
33
@ Advice .OnMethodExit (suppress = Throwable .class )
33
34
public static void onExit (@ Advice .This Object task ) {
35
+ if (TraceContextManager .get () == null ) {
36
+ return ;
37
+ }
34
38
final Object captured = ArexThreadLocal .Transmitter .capture ();
35
39
if (captured != null ) {
36
40
Cache .CAPTURED_CACHE .put (task , captured );
You can’t perform that action at this time.
0 commit comments