Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
fix NPE for older slf4j versions, remove added values
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan.Praetsch authored and StephanPraetsch committed Apr 18, 2024
1 parent 74d3445 commit 9b74b0c
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,16 @@ public class LongRunningMessageHandler<I, O> {
public Future<?> submit(Runnable task) {
Map<String, String> current = MDC.getCopyOfContextMap();
return super.submit(() -> {
MDC.setContextMap(current);
task.run();
try {
if (current != null) {
current.forEach(MDC::put);
}
task.run();
} finally {
if (current != null) {
current.keySet().forEach(MDC::remove);
}
}
});
}
};
Expand Down

0 comments on commit 9b74b0c

Please sign in to comment.