From: Michael Vorburger Date: Mon, 12 Jun 2017 11:16:26 +0000 (+0200) Subject: Bug 8662 RefreshingSCPModuleInfoRegistry synchronized X-Git-Tag: release/nitrogen~123 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=81ac3baf3f0988cc945e3b2514258e440365baf8;ds=sidebyside Bug 8662 RefreshingSCPModuleInfoRegistry synchronized Looks like (as seen on Bug 8662) there can be race conditions between RefreshingSCPModuleInfoRegistry's updateService() and close() ... The NPE in that bug on the "osgiReg" happens even if though that's guarded inside a if (this.osgiReg != null), but it's during shutdown, so presumably it JUST got set to null in close() ? A "synchronized" on both methods should prevent that. Change-Id: I607092e3174c2fd0447d8548f4933624acd6a29b Signed-off-by: Michael Vorburger --- diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RefreshingSCPModuleInfoRegistry.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RefreshingSCPModuleInfoRegistry.java index 6217476fa9..fcde347881 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RefreshingSCPModuleInfoRegistry.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RefreshingSCPModuleInfoRegistry.java @@ -51,8 +51,8 @@ public class RefreshingSCPModuleInfoRegistry implements ModuleInfoRegistry, Auto .registerService(SchemaContextProvider.class, schemaContextProvider, new Hashtable()); } - public void updateService() { - if(this.osgiReg != null) { + public synchronized void updateService() { + if (this.osgiReg != null) { try { this.bindingContextProvider.update(this.classLoadingStrat, this.schemaContextProvider); @@ -75,8 +75,8 @@ public class RefreshingSCPModuleInfoRegistry implements ModuleInfoRegistry, Auto } @Override - public void close() throws Exception { - if(this.osgiReg != null) { + public synchronized void close() throws Exception { + if (this.osgiReg != null) { this.osgiReg.unregister(); }