From: Flavio Fernandes Date: Wed, 13 Aug 2014 02:37:16 +0000 (-0400) Subject: Better handle remove interface from router for unknown port uuid X-Git-Tag: release/helium~300^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=4f86ec1a7c51b28d066bcd34b7cb47cfed7eff1e;ds=inline Better handle remove interface from router for unknown port uuid When doing "Remove interface from router" and only port uuid is provided; the lookup in hash map may return null. If so, there needs to be a check against NPE. Change-Id: Ibaea49ac3fdfc08e92c95e818e5ec82628822f3f Ref: http://docs.openstack.org/api/openstack-network/2.0/content/PUT_removeRouterInterface__v2.0_routers_remove_router_interface_router_ext.html Signed-off-by: Flavio Fernandes --- diff --git a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRoutersNorthbound.java b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRoutersNorthbound.java index 806e853b36..0c02adad8a 100644 --- a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRoutersNorthbound.java +++ b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronRoutersNorthbound.java @@ -527,6 +527,9 @@ public class NeutronRoutersNorthbound { if (input.getPortUUID() != null && input.getSubnetUUID() == null) { NeutronRouter_Interface targetInterface = target.getInterfaces().get(input.getPortUUID()); + if (targetInterface == null) { + throw new ResourceNotFoundException("Router interface not found for given Port UUID"); + } input.setSubnetUUID(targetInterface.getSubnetUUID()); input.setID(target.getID()); input.setTenantID(target.getTenantID()); @@ -554,7 +557,7 @@ public class NeutronRoutersNorthbound { throw new ResourceNotFoundException("Port UUID not found"); } if (port.getFixedIPs() == null) { - throw new ResourceNotFoundException("Port UUID jas no fixed IPs"); + throw new ResourceNotFoundException("Port UUID has no fixed IPs"); } NeutronSubnet subnet = subnetInterface.getSubnet(input.getSubnetUUID()); if (subnet == null) {