Skip to content

Commit e8d2a47

Browse files
committed
Avoid calling in the same thread
1 parent 7381fd1 commit e8d2a47

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

discovery-agent-starter/src/main/java/com/nepxion/discovery/agent/plugin/spring/async/WrapCallable.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ public WrapCallable(Callable<T> callable) {
2727

2828
@Override
2929
public T call() throws Exception {
30-
31-
//Avoid calling in the same thread.
30+
// Avoid calling in the same thread
3231
if (asyncContext.getOriginThread().equals(Thread.currentThread())) {
3332
return callable.call();
3433
}
3534

36-
//Call the original method and copy some objects held by ThreadLocal.
35+
// Call the original method and copy some objects held by ThreadLocal
3736
Object[] objects = asyncContext.getObjects();
3837
ThreadLocalCopier.before(objects);
3938
try {

discovery-agent-starter/src/main/java/com/nepxion/discovery/agent/plugin/thread/interceptor/ThreadCallInterceptor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public static void before(Object object) {
2121
if (null == asyncContext) {
2222
return;
2323
}
24-
//Avoid calling in the same thread.
24+
25+
// Avoid calling in the same thread
2526
if (asyncContext.getOriginThread().equals(Thread.currentThread())) {
2627
return;
2728
}
@@ -37,10 +38,12 @@ public static void after(Object object) {
3738
if (null == asyncContext) {
3839
return;
3940
}
40-
//Avoid calling in the same thread.
41+
42+
// Avoid calling in the same thread
4143
if (asyncContext.getOriginThread().equals(Thread.currentThread())) {
4244
return;
4345
}
46+
4447
ThreadLocalCopier.after();
4548
}
4649
}

0 commit comments

Comments
 (0)