Handle new base type provided by MD-SAL 35/29935/1
authorStephen Kitt <skitt@redhat.com>
Thu, 19 Nov 2015 17:41:29 +0000 (18:41 +0100)
committerStephen Kitt <skitt@redhat.com>
Thu, 19 Nov 2015 17:44:13 +0000 (18:44 +0100)
When deserialized, OvsdbBridgeAugmentation's datapathType is now
initialized as DatapathTypeBase instead of null. This is now handled
as an absent value in SouthboundMapper instead of producing an
IllegalArgumentException.

The exception's message is clarified to trace the unknown datapath
type class, instead of the value retrieved from the map (which is
always null in this case).

Change-Id: Ie10ff09878bf182d4747d63f1580a37dfd71ac88
Signed-off-by: Stephen Kitt <skitt@redhat.com>
openstack/net-virt-it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/it/SouthboundMapper.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundMapper.java

index 03b19a8bbd10e6b9cadc54fecb6fe16774dbc0e1..7c7f43493c0dfd691cb1b74459d6b0b2fa34ddc2 100644 (file)
@@ -154,12 +154,10 @@ public class SouthboundMapper {
     public static String createDatapathType(OvsdbBridgeAugmentation mdsalbridge) {
         String datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(DatapathTypeSystem.class);
 
-        if (mdsalbridge.getDatapathType() != null) {
-            if (SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType()) != null) {
-                datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType());
-            } else {
-                throw new IllegalArgumentException("Unknown datapath type "
-                        + SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType()));
+        if (mdsalbridge.getDatapathType() != null && !mdsalbridge.getDatapathType().equals(DatapathTypeBase.class)) {
+            datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType());
+            if (datapathtype == null) {
+                throw new IllegalArgumentException("Unknown datapath type " + mdsalbridge.getDatapathType().getName());
             }
         }
         return datapathtype;
index 6055ca05f4f9d27e889b69dff40d6a307323479b..4f5ae1730bc35538099d788e9f221848cb273f09 100644 (file)
@@ -177,14 +177,12 @@ public class SouthboundMapper {
     }
 
     public static String createDatapathType(OvsdbBridgeAugmentation mdsalbridge) {
-        String datapathtype = new String(SouthboundConstants.DATAPATH_TYPE_MAP.get(DatapathTypeSystem.class));
+        String datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(DatapathTypeSystem.class);
 
-        if (mdsalbridge.getDatapathType() != null) {
-            if (SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType()) != null) {
-                datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType());
-            } else {
-                throw new IllegalArgumentException("Unknown datapath type "
-                        + SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType()));
+        if (mdsalbridge.getDatapathType() != null && !mdsalbridge.getDatapathType().equals(DatapathTypeBase.class)) {
+            datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType());
+            if (datapathtype == null) {
+                throw new IllegalArgumentException("Unknown datapath type " + mdsalbridge.getDatapathType().getName());
             }
         }
         return datapathtype;