diff --git a/sermant-plugins/sermant-router/router-transmit-plugin/src/main/java/io/sermant/router/transmit/wrapper/AbstractThreadWrapper.java b/sermant-plugins/sermant-router/router-transmit-plugin/src/main/java/io/sermant/router/transmit/wrapper/AbstractThreadWrapper.java index cbf2d81e36..b95358cc03 100644 --- a/sermant-plugins/sermant-router/router-transmit-plugin/src/main/java/io/sermant/router/transmit/wrapper/AbstractThreadWrapper.java +++ b/sermant-plugins/sermant-router/router-transmit-plugin/src/main/java/io/sermant/router/transmit/wrapper/AbstractThreadWrapper.java @@ -45,6 +45,8 @@ public abstract class AbstractThreadWrapper { private final boolean cannotTransmit; + private final long threadId; + /** * Constructor * @@ -66,6 +68,7 @@ public AbstractThreadWrapper(Runnable runnable, Callable callable, RequestTag this.requestData = requestData; } this.cannotTransmit = cannotTransmit; + this.threadId = Thread.currentThread().getId(); } /** @@ -117,6 +120,9 @@ private void before(Object obj) { } private void after() { + if (threadId == Thread.currentThread().getId()) { + return; + } ThreadLocalUtils.removeRequestTag(); ThreadLocalUtils.removeRequestData(); } diff --git a/sermant-plugins/sermant-tag-transmission/tag-transmission-crossthread-plugin/src/main/java/io/sermant/tag/transmission/crossthread/wrapper/AbstractThreadWrapper.java b/sermant-plugins/sermant-tag-transmission/tag-transmission-crossthread-plugin/src/main/java/io/sermant/tag/transmission/crossthread/wrapper/AbstractThreadWrapper.java index cc0a8f5dfd..8e1832656f 100644 --- a/sermant-plugins/sermant-tag-transmission/tag-transmission-crossthread-plugin/src/main/java/io/sermant/tag/transmission/crossthread/wrapper/AbstractThreadWrapper.java +++ b/sermant-plugins/sermant-tag-transmission/tag-transmission-crossthread-plugin/src/main/java/io/sermant/tag/transmission/crossthread/wrapper/AbstractThreadWrapper.java @@ -51,6 +51,8 @@ public abstract class AbstractThreadWrapper { private final boolean cannotTransmit; + private final long threadId; + /** * constructor * @@ -73,6 +75,7 @@ public AbstractThreadWrapper(Runnable runnable, Callable callable, TrafficMes } this.cannotTransmit = cannotTransmit; this.executorName = executorName; + this.threadId = Thread.currentThread().getId(); } /** @@ -133,6 +136,9 @@ protected void before(Object obj) { * Post method executed by thread object */ protected void after() { + if (threadId == Thread.currentThread().getId()) { + return; + } TrafficUtils.removeTrafficTag(); TrafficUtils.removeTrafficData(); }