Skip to content

Commit bea387d

Browse files
committed
propagate mdc to child thread
1 parent eddf77b commit bea387d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

launcher/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
<dependency>
5555
<groupId>org.slf4j</groupId>
5656
<artifactId>slf4j-api</artifactId>
57-
<scope>test</scope>
5857
</dependency>
5958
<dependency>
6059
<groupId>org.slf4j</groupId>

launcher/src/main/java/org/apache/spark/launcher/InProcessAppHandle.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717

1818
package org.apache.spark.launcher;
1919

20+
import org.slf4j.MDC;
21+
2022
import java.lang.reflect.Method;
23+
import java.util.Map;
2124
import java.util.concurrent.atomic.AtomicLong;
2225
import java.util.logging.Level;
2326
import java.util.logging.Logger;
@@ -58,7 +61,9 @@ synchronized void start(String appName, Method main, String[] args) {
5861
appName = "..." + appName.substring(appName.length() - MAX_APP_NAME_LEN);
5962
}
6063

64+
Map<String, String> mdcContextMap = MDC.getCopyOfContextMap();
6165
app = new Thread(() -> {
66+
MDC.setContextMap(mdcContextMap);
6267
try {
6368
main.invoke(null, (Object) args);
6469
} catch (Throwable t) {

0 commit comments

Comments
 (0)