File tree Expand file tree Collapse file tree 1 file changed +6
-16
lines changed
components/camel-mdc/src/main/java/org/apache/camel/mdc Expand file tree Collapse file tree 1 file changed +6
-16
lines changed Original file line number Diff line number Diff line change 2626import org .apache .camel .NamedNode ;
2727import org .apache .camel .Processor ;
2828import org .apache .camel .spi .InterceptStrategy ;
29+ import org .apache .camel .support .AsyncCallbackToCompletableFutureAdapter ;
2930import org .apache .camel .support .AsyncProcessorConverterHelper ;
3031import org .slf4j .MDC ;
3132
@@ -93,23 +94,12 @@ public void process(Exchange exchange) throws Exception {
9394
9495 @ Override
9596 public CompletableFuture <Exchange > processAsync (Exchange exchange ) {
96- CompletableFuture <Exchange > future = new CompletableFuture <>();
97- Map <String , String > previousContext = MDC .getCopyOfContextMap ();
98- mdcService .setMDC (exchange );
99- asyncProcessor .process (exchange , doneSync -> {
100- if (exchange .getException () != null ) {
101- future .completeExceptionally (exchange .getException ());
102- } else {
103- future .complete (exchange );
104- }
105- if (previousContext != null ) {
106- MDC .setContextMap (previousContext );
107- } else {
108- MDC .clear ();
109- }
110- });
111- return future ;
97+ AsyncCallbackToCompletableFutureAdapter <Exchange > callback
98+ = new AsyncCallbackToCompletableFutureAdapter <>(exchange );
99+ process (exchange , callback );
100+ return callback .getFuture ();
112101 }
102+
113103 };
114104 }
115105
You can’t perform that action at this time.
0 commit comments