Skip to content

Commit b6406c2

Browse files
committed
synchronize shutdown hook
1 parent 83bdee0 commit b6406c2

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

  • dd-java-agent/instrumentation/spark/spark-common/src/main/java/datadog/trace/instrumentation/spark

dd-java-agent/instrumentation/spark/spark-common/src/main/java/datadog/trace/instrumentation/spark/SparkLauncherAdvice.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ public static synchronized void createLauncherSpan(String resource) {
4040
.addShutdownHook(
4141
new Thread(
4242
() -> {
43-
AgentSpan s = launcherSpan;
44-
if (s != null) {
45-
log.info("Finishing spark.launcher span from shutdown hook");
46-
s.finish();
47-
launcherSpan = null;
43+
synchronized (SparkLauncherAdvice.class) {
44+
AgentSpan s = launcherSpan;
45+
if (s != null) {
46+
log.info("Finishing spark.launcher span from shutdown hook");
47+
s.finish();
48+
launcherSpan = null;
49+
}
4850
}
4951
}));
5052
}

0 commit comments

Comments
 (0)