[VOL-4495] Do not remove NNI flows, they are only wiped out on device disconnect

Change-Id: I904def137485f66a86fa9241a98e7ddeda10f481
diff --git a/impl/src/main/java/org/opencord/olt/impl/Olt.java b/impl/src/main/java/org/opencord/olt/impl/Olt.java
index 747a0b4..af3eed8 100644
--- a/impl/src/main/java/org/opencord/olt/impl/Olt.java
+++ b/impl/src/main/java/org/opencord/olt/impl/Olt.java
@@ -852,8 +852,12 @@
                 }
             } else {
                 if (oltDeviceService.isNniPort(device, port.number())) {
-                    // NOTE this may need to be handled on DEVICE_REMOVE as we don't disable the NNI
-                    oltFlowService.handleNniFlows(device, port, OltFlowService.FlowOperation.REMOVE);
+                    // NOTE the NNI is only disabled if the OLT shuts down (reboot or failure).
+                    // In that case the flows are purged anyway, so there's no need to deal with them,
+                    // it would actually be counter-productive as the openflow connection is severed and they won't
+                    // be correctly processed
+                    log.debug("NNI port went down, " +
+                            "ignoring event as flows will be removed in the generic device cleanup");
                 } else {
                     post(new AccessDeviceEvent(AccessDeviceEvent.Type.UNI_REMOVED, device.id(), port));
                     // NOTE we are assuming that if a subscriber has default eapol
diff --git a/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java b/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java
index f798e25..f1ef425 100644
--- a/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java
+++ b/impl/src/main/java/org/opencord/olt/impl/OltFlowService.java
@@ -659,11 +659,7 @@
     @Override
     public void purgeDeviceFlows(DeviceId deviceId) {
         log.debug("Purging flows on device {}", deviceId);
-        try {
-            flowRuleService.purgeFlowRules(deviceId);
-        } catch (Exception e) {
-            log.error("Cannot purge flow rules", e);
-        }
+        flowRuleService.purgeFlowRules(deviceId);
 
         // removing the status from the cpStatus map
         if (log.isTraceEnabled()) {
@@ -678,8 +674,6 @@
                     cpStatus.remove(entry.getKey());
                 }
             }
-        } catch (Exception e) {
-            log.error("Cannot wipe out cpStatus", e);
         } finally {
             cpStatusWriteLock.unlock();
         }
@@ -697,8 +691,6 @@
                     provisionedSubscribers.remove(entry.getKey());
                 }
             }
-        } catch (Exception e) {
-            log.error("Cannot wipe out subscribers", e);
         } finally {
             provisionedSubscribersWriteLock.unlock();
         }
diff --git a/impl/src/test/java/org/opencord/olt/impl/OltDeviceListenerTest.java b/impl/src/test/java/org/opencord/olt/impl/OltDeviceListenerTest.java
index f8229da..0d5204f 100644
--- a/impl/src/test/java/org/opencord/olt/impl/OltDeviceListenerTest.java
+++ b/impl/src/test/java/org/opencord/olt/impl/OltDeviceListenerTest.java
@@ -50,6 +50,7 @@
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
@@ -149,8 +150,9 @@
         DeviceEvent nniDisabledEvent = new DeviceEvent(DeviceEvent.Type.PORT_UPDATED, testDevice, disabledNniPort);
         oltDeviceListener.event(nniDisabledEvent);
 
+        // when the NNI goes down we ignore the event
         assert olt.eventsQueues.isEmpty();
-        verify(olt.oltFlowService, times(1))
+        verify(olt.oltFlowService, never())
                 .handleNniFlows(testDevice, disabledNniPort, OltFlowService.FlowOperation.REMOVE);
 
         // when we disable the device we receive a PORT_REMOVED event with status ENABLED