site improvement, warnings removal, applied queueKeeper, fixed tests, errorHandler...
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / session / OFSessionUtil.java
index a4c20a47ecccac64f41828c2c25763a31518732b..a7e367396a22be88088c4750e79806bd94a39164 100644 (file)
@@ -37,8 +37,7 @@ public abstract class OFSessionUtil {
             GetFeaturesOutput features, short version) {
         SwitchConnectionDistinguisher sessionKey = createSwitchSessionKey(features
                 .getDatapathId());
-        SessionContext sessionContext = getSessionManager().getSessionContext(
-                sessionKey);
+        SessionContext sessionContext = getSessionManager().getSessionContext(sessionKey);
 
         if (features.getAuxiliaryId() == 0) {
             // handle primary
@@ -59,7 +58,7 @@ public abstract class OFSessionUtil {
         } else {
             // handle auxiliary
             if (sessionContext == null) {
-                LOG.warn("unexpected auxiliary connection - primary connection missing: "
+                throw new IllegalStateException("unexpected auxiliary connection - primary connection missing: "
                         + dumpDataPathId(features.getDatapathId()));
             } else {
                 // register auxiliary conductor into existing sessionContext
@@ -80,6 +79,16 @@ public abstract class OFSessionUtil {
                 connectionConductor.setConnectionCookie(auxiliaryKey);
             }
         }
+        
+        // check registration result
+        SessionContext resulContext = getSessionManager().getSessionContext(sessionKey);
+        if (resulContext == null) {
+            throw new IllegalStateException("session context registration failed");
+        } else {
+            if (!resulContext.isValid()) {
+                throw new IllegalStateException("registered session context is invalid");
+            }
+        }
     }
 
     /**