BUG-8143: issue a JVM restart
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / config / yang / config / actor_system_provider / impl / ActorSystemProviderImpl.java
index 585218f121e0edcbb25a6509989985fb15ea3e2b..5b6e447d0b09e165e66178bb596bf6d813bf5d7d 100644 (file)
@@ -12,6 +12,8 @@ import akka.actor.Props;
 import akka.osgi.BundleDelegatingClassLoader;
 import com.typesafe.config.Config;
 import com.typesafe.config.ConfigFactory;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.concurrent.TimeUnit;
 import org.opendaylight.controller.cluster.ActorSystemProvider;
 import org.opendaylight.controller.cluster.ActorSystemProviderListener;
@@ -40,8 +42,9 @@ public class ActorSystemProviderImpl implements ActorSystemProvider, AutoCloseab
 
         final Bundle bundle = bundleContext.getBundle();
 
-        final BundleDelegatingClassLoader classLoader = new BundleDelegatingClassLoader(bundle, Thread.currentThread()
-                .getContextClassLoader());
+        final BundleDelegatingClassLoader classLoader = AccessController.doPrivileged(
+            (PrivilegedAction<BundleDelegatingClassLoader>) () ->
+                new BundleDelegatingClassLoader(bundle, Thread.currentThread().getContextClassLoader()));
 
         final AkkaConfigurationReader configurationReader = new FileAkkaConfigurationReader();
         final Config akkaConfig = ConfigFactory.load(configurationReader.read()).getConfig(CONFIGURATION_NAME);
@@ -53,10 +56,9 @@ public class ActorSystemProviderImpl implements ActorSystemProvider, AutoCloseab
         actorSystem.actorOf(QuarantinedMonitorActor.props(() -> {
             // restart the entire karaf container
             LOG.warn("Restarting karaf container");
-            System.setProperty("karaf.restart", "true");
+            System.setProperty("karaf.restart.jvm", "true");
             bundleContext.getBundle(0).stop();
         }), QuarantinedMonitorActor.ADDRESS);
-
     }
 
     @Override