BUG-1075: ingress back pressure
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / session / SessionManagerOFImpl.java
index 24ba19a676d1247cfec53b3a26197dd808f42024..a314018d777939e29bbbeea057bb2a3bce23a5ff 100644 (file)
@@ -54,9 +54,13 @@ public class SessionManagerOFImpl implements SessionManager {
     /**
      * @return singleton instance
      */
-    public static synchronized SessionManager getInstance() {
+    public static SessionManager getInstance() {
         if (instance == null) {
-            instance = new SessionManagerOFImpl();
+            synchronized (SessionContextOFImpl.class) {
+                if (instance == null) {
+                    instance = new SessionManagerOFImpl();
+                }
+            }
         }
         return instance;
     }
@@ -64,9 +68,15 @@ public class SessionManagerOFImpl implements SessionManager {
     /**
      * close and release singleton instace
      */
-    public static synchronized void releaseInstance() {
-        instance.close();
-        instance = null;
+    public static void releaseInstance() {
+        if (instance != null) {
+            synchronized (SessionManagerOFImpl.class) {
+                if (instance != null) {
+                    instance.close();
+                    instance = null;
+                }
+            }
+        }
     }
 
     private SessionManagerOFImpl() {