Skip to content

Commit 0684bb7

Browse files
committed
fix(components): set MDC stack when sync as well
1 parent e66561c commit 0684bb7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

components/camel-mdc/src/main/java/org/apache/camel/mdc/MDCProcessorsInterceptStrategy.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,17 @@ public boolean process(Exchange exchange, AsyncCallback callback) {
7777

7878
@Override
7979
public void process(Exchange exchange) throws Exception {
80+
Map<String, String> previousContext = MDC.getCopyOfContextMap();
8081
mdcService.setMDC(exchange);
8182
try {
8283
asyncProcessor.process(exchange);
8384
} finally {
8485
mdcService.unsetMDC(exchange);
86+
if (previousContext != null) {
87+
MDC.setContextMap(previousContext);
88+
} else {
89+
MDC.clear();
90+
}
8591
}
8692
}
8793

0 commit comments

Comments
 (0)