Speed up OsgiBundleScanningSchemaService close
[mdsal.git] / dom / mdsal-dom-broker / src / main / java / org / opendaylight / mdsal / dom / broker / osgi / OsgiBundleScanningSchemaService.java
index 0e544a84017efef9cdc13bee70ea19653bde66bc..bc057e74f4d5a8067560c8f57e7c236ecd5aa890 100644 (file)
@@ -50,6 +50,7 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D
     private ServiceTracker<SchemaContextListener, SchemaContextListener> listenerTracker;
     private BundleTracker<Iterable<Registration>> bundleTracker;
     private boolean starting = true;
+    private volatile boolean stopping;
     private static OsgiBundleScanningSchemaService instance;
 
     private OsgiBundleScanningSchemaService(final BundleContext context) {
@@ -128,6 +129,7 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D
 
     @Override
     public void close() {
+        stopping = true;
         if (bundleTracker != null) {
             bundleTracker.close();
         }
@@ -241,7 +243,7 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D
     }
 
     public synchronized void tryToUpdateSchemaContext() {
-        if (starting) {
+        if (starting || stopping) {
             return;
         }
         final Optional<SchemaContext> schema = contextResolver.getSchemaContext();