This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0684bb781f0285410a00fd238ecd4fda0040d55a
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Fri Dec 19 10:40:55 2025 +0100

    fix(components): set MDC stack when sync as well
---
 .../java/org/apache/camel/mdc/MDCProcessorsInterceptStrategy.java   | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git 
a/components/camel-mdc/src/main/java/org/apache/camel/mdc/MDCProcessorsInterceptStrategy.java
 
b/components/camel-mdc/src/main/java/org/apache/camel/mdc/MDCProcessorsInterceptStrategy.java
index 956374c49987..3e079e71fb7b 100644
--- 
a/components/camel-mdc/src/main/java/org/apache/camel/mdc/MDCProcessorsInterceptStrategy.java
+++ 
b/components/camel-mdc/src/main/java/org/apache/camel/mdc/MDCProcessorsInterceptStrategy.java
@@ -77,11 +77,17 @@ public class MDCProcessorsInterceptStrategy implements 
InterceptStrategy {
 
             @Override
             public void process(Exchange exchange) throws Exception {
+                Map<String, String> previousContext = 
MDC.getCopyOfContextMap();
                 mdcService.setMDC(exchange);
                 try {
                     asyncProcessor.process(exchange);
                 } finally {
                     mdcService.unsetMDC(exchange);
+                    if (previousContext != null) {
+                        MDC.setContextMap(previousContext);
+                    } else {
+                        MDC.clear();
+                    }
                 }
             }
 

Reply via email to