[VOL-3922] Invalidating the pipeliner cache if the driver for a device changes

Change-Id: Ie578c9536960ce2d8ad8deff4e7494ded04397ea
diff --git a/core/net/src/main/java/org/onosproject/net/driver/impl/DriverRegistryManager.java b/core/net/src/main/java/org/onosproject/net/driver/impl/DriverRegistryManager.java
index 546f40a..834b88c 100644
--- a/core/net/src/main/java/org/onosproject/net/driver/impl/DriverRegistryManager.java
+++ b/core/net/src/main/java/org/onosproject/net/driver/impl/DriverRegistryManager.java
@@ -77,7 +77,7 @@
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private static final String FORMAT = "Required drivers: {}";
+    private static final String FORMAT = "Modified, Required drivers: {}";
     private static final String COMMA = ",";
     private static final String NO_DRIVER = "Driver not found";
     private static final String DEFAULT = "default";
@@ -179,6 +179,8 @@
     private synchronized void checkRequiredDrivers() {
         Set<String> driverSet = registeredDrivers();
         boolean isReady = driverSet.containsAll(requiredDriverSet);
+        log.debug("RequiredDriverSet {}, isReady {}, isStarted {}",
+                  requiredDriverSet, isReady, isStarted);
         if (isReady && !isStarted) {
             log.info("Starting driver subsystem");
             componentService.activate(null, DRIVER_COMPONENT);
diff --git a/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java b/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java
index 6cc355d..597e91e 100644
--- a/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java
+++ b/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java
@@ -579,8 +579,12 @@
         @Override
         public void event(DriverEvent event) {
             String driverName = event.subject().name();
+            //we invalidate the pipeliner if the event is for the same driver or
+            // if we have the device in the cache but the driver for it changed.
             driverHandlers.entrySet().stream()
-                    .filter(e -> driverName.equals(e.getValue().driver().name()))
+                    .filter(e -> driverName.equals(e.getValue().driver().name())
+                            || !e.getValue().driver().name()
+                            .equals(driverService.getDriver(e.getKey()).name()))
                     .map(Map.Entry::getKey)
                     .distinct()
                     .forEach(FlowObjectiveManager.this::invalidatePipeliner);