Fix NPE in FloatingIpGarpHandler.sendGarpOnInterface 44/44644/1
authorRavit Peretz <ravit.peretz@hpe.com>
Thu, 25 Aug 2016 08:24:43 +0000 (11:24 +0300)
committerRavit Peretz <ravit.peretz@hpe.com>
Thu, 25 Aug 2016 08:25:55 +0000 (11:25 +0300)
Change-Id: I03ecf452559649391ffee5b3597ef9cf95479224
Signed-off-by: Ravit Peretz <ravit.peretz@hpe.com>
vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/FloatingIpGarpHandler.java

index 71f4872b88ffdc738e192d1e5f107a7ece7234ac..e33954892dc813fb3db90c87dc25c96b65ece020 100644 (file)
@@ -99,18 +99,16 @@ public class FloatingIpGarpHandler extends AsyncDataTreeChangeListenerBase<Route
     }
 
     private void sendGarpOnInterface(IpAddress ip, MacAddress floatingIpMac, String externalInterface) {
-        GetPortFromInterfaceInput getPortFromInterfaceInput = new GetPortFromInterfaceInputBuilder().setIntfName(externalInterface).build();
-        Future<RpcResult<GetPortFromInterfaceOutput>> interfacePort = intfRpc.getPortFromInterface(getPortFromInterfaceInput);
         try {
+            GetPortFromInterfaceInput getPortFromInterfaceInput = new GetPortFromInterfaceInputBuilder().setIntfName(externalInterface).build();
+            Future<RpcResult<GetPortFromInterfaceOutput>> interfacePort = intfRpc.getPortFromInterface(getPortFromInterfaceInput);
             BigInteger dpId = interfacePort.get().getResult().getDpid();
             String portName = interfacePort.get().getResult().getPortname();
             NodeConnectorRef ingress = MDSALUtil.getNodeConnRef(dpId, portName);
             byte[] ipBytes = InetAddresses.forString(ip.getIpv4Address().getValue()).getAddress();
             TransmitPacketInput arpRequestInput = ArpUtils.createArpRequestInput(dpId, ArpUtils.getMacInBytes(floatingIpMac.getValue()), ipBytes, ipBytes, ingress);
             packetService.transmitPacket(arpRequestInput);
-        } catch (InterruptedException e) {
-            LOG.warn("Faild to send GARP. rpc call getPortFromInterface did not return with a value.");
-        } catch (ExecutionException e) {
+        } catch (InterruptedException|ExecutionException e) {
             LOG.warn("Faild to send GARP. rpc call getPortFromInterface did not return with a value.");
         }
     }