Skip to content

Commit 47af939

Browse files
Avoid race conditions
1 parent d0e0c56 commit 47af939

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

dd-java-agent/appsec/src/main/java/com/datadog/appsec/AppSecSystem.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,12 @@ public static void stop() {
129129
return;
130130
}
131131
REPLACEABLE_EVENT_PRODUCER = null;
132-
STOP_SUBSCRIPTION_SERVICE.run();
133-
STOP_SUBSCRIPTION_SERVICE = null;
134-
RESET_SUBSCRIPTION_SERVICE = null;
132+
final Runnable stop = STOP_SUBSCRIPTION_SERVICE;
133+
if (stop != null) {
134+
stop.run();
135+
STOP_SUBSCRIPTION_SERVICE = null;
136+
RESET_SUBSCRIPTION_SERVICE = null;
137+
}
135138
Blocking.setBlockingService(BlockingService.NOOP);
136139

137140
APP_SEC_CONFIG_SERVICE.close();
@@ -180,8 +183,9 @@ private static void reloadSubscriptions(
180183

181184
replaceableEventProducerService.replaceEventProducerService(newEd);
182185

183-
if (RESET_SUBSCRIPTION_SERVICE != null) {
184-
RESET_SUBSCRIPTION_SERVICE.run();
186+
final Runnable reset = RESET_SUBSCRIPTION_SERVICE;
187+
if (reset != null) {
188+
reset.run();
185189
}
186190
}
187191

0 commit comments

Comments
 (0)