RxJavaPlugins.setScheduleHandler(runnable -> {
Map<String, String> context = MDC.getCopyOfContextMap();
return () -> {
Map<String, String> beforeContext = MDC.getCopyOfContextMap();
if (context == null) {
MDC.clear();
} else {
MDC.setContextMap(context);
}
try {
runnable.run();
} finally {
if (beforeContext == null) {
MDC.clear();
} else {
MDC.setContextMap(beforeContext);
}
}
};
});
Last active
August 29, 2018 08:49
-
-
Save wreulicke/09f904dc338ac82edacc2836b9b9dfca to your computer and use it in GitHub Desktop.
RxJava2でMDCのcontextを引き回すコード
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment