Fix union use issues 33/73833/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 9 Jul 2018 09:11:49 +0000 (11:11 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 9 Jul 2018 09:11:49 +0000 (11:11 +0200)
PortTranslatorUtilTest is using invalid port number, fix that.
PortUpdateTranslator attempted to create an invalid union, where
both members are null, fix that by checking if there is a port
number present.

Change-Id: Ieaae6eaadd397e990e813d429bb104ad4db13240
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslator.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/PortTranslatorUtilTest.java

index 686744c50895f4b1916cee303b2963ed96286d59..baec4d961e82f6a67ce69b4411db2c34fe3bceea 100644 (file)
@@ -57,7 +57,11 @@ public class PortUpdateTranslator implements MessageTranslator<PortGrouping, Flo
         builder.setHardwareAddress(input.getHwAddr());
         builder.setMaximumSpeed(input.getMaxSpeed());
         builder.setName(input.getName());
-        builder.setPortNumber(new PortNumberUni(input.getPortNo()));
+
+        final Long portNo = input.getPortNo();
+        if (portNo != null) {
+            builder.setPortNumber(new PortNumberUni(portNo));
+        }
 
         return builder.build();
     }
index c14803e5cc40d2114dc0ef7e3acf3d70c56ced75..3a8e57c6334a2e6dde6044dfc67fae4f79754a4c 100644 (file)
@@ -102,7 +102,7 @@ public class PortTranslatorUtilTest {
         Short version = OpenflowVersion.OF10.getVersion();
 
         BigInteger dataPathId = BigInteger.ONE;
-        Long portNumber = Long.MAX_VALUE;
+        Long portNumber = 4294967295L;
         PortGrouping portGrouping = mockPortGrouping();
 
         NodeConnectorUpdated nodeConnectorUpdated = PortTranslatorUtil