NPE in NeutronFloatingToFixedIpMappingChangeListener 40/91440/2
authorChetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Mon, 20 Jul 2020 05:03:39 +0000 (10:33 +0530)
committerChetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Mon, 20 Jul 2020 06:09:21 +0000 (11:39 +0530)
JIRA : NETVIRT-1690

Signed-off-by: Chetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Change-Id: I83f816520fa87f39ff8b122361cf1b02bc2eb034
Signed-off-by: Chetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronFloatingToFixedIpMappingChangeListener.java

index 29f56dcd56858abc02167e54bb15075e39301d8b..487f0f5a87115dcb18a6fd6fde2391f79301cf75 100644 (file)
@@ -11,6 +11,8 @@ import static org.opendaylight.netvirt.neutronvpn.NeutronvpnUtils.buildfloatingI
 
 import edu.umd.cs.findbugs.annotations.CheckReturnValue;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -162,13 +164,12 @@ public class NeutronFloatingToFixedIpMappingChangeListener extends AbstractAsync
                             .setPortName(fixedNeutronPortName);
                 }
                 if (fixedIpAddress != null) {
-                    List<InternalToExternalPortMap> intExtPortMapList
-                            = new ArrayList<InternalToExternalPortMap>(fixedNeutronPortBuilder
-                            .getInternalToExternalPortMap() != null ? fixedNeutronPortBuilder
-                            .getInternalToExternalPortMap().values() : null);
-                    if (intExtPortMapList == null) {
-                        intExtPortMapList = new ArrayList<>();
-                    }
+                    Collection<InternalToExternalPortMap> intExtPortMapCollection = fixedNeutronPortBuilder
+                        .getInternalToExternalPortMap() != null ? fixedNeutronPortBuilder
+                        .getInternalToExternalPortMap().values() : null;
+                    List<InternalToExternalPortMap> intExtPortMapList =
+                        new ArrayList<InternalToExternalPortMap>(intExtPortMapCollection != null
+                            ? intExtPortMapCollection : Collections.emptyList());
                     InternalToExternalPortMap intExtPortMap = new InternalToExternalPortMapBuilder().withKey(new
                             InternalToExternalPortMapKey(fixedIpAddress)).setInternalIp(fixedIpAddress)
                             .setExternalIp(floatingIpAddress).setExternalId(floatingIpId).build();