Ensure periodic polling thread to survive exception.

- Exception from a Device should not hurt other devices
- Exception during device iteration process should not
  leak leading periodic task to die.

Change-Id: I816d5e9430ec236a2809983189382d326a02e251
diff --git a/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleDriverProvider.java b/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleDriverProvider.java
index a0ad439..c3ad08b 100644
--- a/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleDriverProvider.java
+++ b/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleDriverProvider.java
@@ -174,15 +174,23 @@
     }
 
     private void pollDeviceFlowEntries(Device device) {
-        providerService.pushFlowMetrics(device.id(), device.as(FlowRuleProgrammable.class).getFlowEntries());
+        try {
+            providerService.pushFlowMetrics(device.id(), device.as(FlowRuleProgrammable.class).getFlowEntries());
+        } catch (Exception e) {
+            log.warn("Exception thrown while polling {}", device.id(), e);
+        }
     }
 
     private void pollFlowEntries() {
-        deviceService.getAvailableDevices().forEach(device -> {
-            if (mastershipService.isLocalMaster(device.id()) && device.is(FlowRuleProgrammable.class)) {
-                pollDeviceFlowEntries(device);
-            }
-        });
+        try {
+            deviceService.getAvailableDevices().forEach(device -> {
+                if (mastershipService.isLocalMaster(device.id()) && device.is(FlowRuleProgrammable.class)) {
+                    pollDeviceFlowEntries(device);
+                }
+            });
+        } catch (Exception e) {
+            log.warn("Exception thrown while polling flows", e);
+        }
     }
 
     private class InternalDeviceListener implements DeviceListener {