Fix NPE triggered after disabling SG on a port
[netvirt.git] / openstack / sfc-translator / impl / src / main / java / org / opendaylight / netvirt / openstack / sfc / translator / portchain / NeutronPortChainListener.java
index 431bc865deb4482976414a2fa21d04add9243947..76c3d714981a26e5970374c4d12091a558d47beb 100644 (file)
@@ -119,12 +119,7 @@ public class NeutronPortChainListener extends DelegatingDataTreeListener<PortCha
     @Override
     public void add(final InstanceIdentifier<PortChain> path, final PortChain newPortChain) {
         processPortChain(newPortChain);
-        eventProcessor.submit(new Runnable() {
-            @Override
-            public void run() {
-                processPortChain(newPortChain);
-            }
-        });
+        eventProcessor.submit(() -> processPortChain(newPortChain));
     }
 
     private void processPortChain(PortChain newPortChain) {
@@ -274,8 +269,13 @@ public class NeutronPortChainListener extends DelegatingDataTreeListener<PortCha
                 LOG.info("Call RPC for creating RSP :{}", rpInput);
                 Future<RpcResult<CreateRenderedPathOutput>> result =  this.rspService.createRenderedPath(rpInput);
                 try {
-                    result.get();
-                    processFlowClassifiers(newPortChain, newPortChain.getFlowClassifiers(), rpInput.getName());
+                    if (result.get() != null) {
+                        CreateRenderedPathOutput output = result.get().getResult();
+                        LOG.debug("RSP name received from SFC : {}", output.getName());
+                        processFlowClassifiers(newPortChain, newPortChain.getFlowClassifiers(), output.getName());
+                    } else {
+                        LOG.error("RSP creation failed : {}", rpInput);
+                    }
                 } catch (InterruptedException | ExecutionException e) {
                     LOG.error("Error occurred during creating Rendered Service Path using RPC call", e);
                 }