Fix broken locking in Restarter.initialize

Closes gh-4955
pull/5013/head
Andy Wilkinson 9 years ago
parent c77a7e0cba
commit 4c1bb38878

@ -525,12 +525,16 @@ public class Restarter {
public static void initialize(String[] args, boolean forceReferenceCleanup, public static void initialize(String[] args, boolean forceReferenceCleanup,
RestartInitializer initializer, boolean restartOnInitialize, RestartInitializer initializer, boolean restartOnInitialize,
RestartListener... listeners) { RestartListener... listeners) {
if (instance == null) { Restarter localInstance = null;
synchronized (Restarter.class) { synchronized (Restarter.class) {
instance = new Restarter(Thread.currentThread(), args, if (instance == null) {
localInstance = new Restarter(Thread.currentThread(), args,
forceReferenceCleanup, initializer, listeners); forceReferenceCleanup, initializer, listeners);
instance = localInstance;
} }
instance.initialize(restartOnInitialize); }
if (localInstance != null) {
localInstance.initialize(restartOnInitialize);
} }
} }

Loading…
Cancel
Save