[ONOS-7533] Extension instruction deserialization failure due to un-available device

Change-Id: I44b179bdb4ef78f6103453a9eec8df661586bed1
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionInstructionSerializer.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionInstructionSerializer.java
index 3df346e..c6d2907 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionInstructionSerializer.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/ExtensionInstructionSerializer.java
@@ -26,6 +26,7 @@
 import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
 import org.onosproject.net.driver.DefaultDriverData;
 import org.onosproject.net.driver.DefaultDriverHandler;
+import org.onosproject.net.driver.Driver;
 import org.onosproject.net.driver.DriverHandler;
 import org.onosproject.net.driver.DriverService;
 import org.onosproject.net.flow.instructions.ExtensionTreatment;
@@ -50,6 +51,10 @@
     public void write(Kryo kryo, Output output, Instructions.ExtensionInstructionWrapper object) {
         kryo.writeClassAndObject(output, object.extensionInstruction().type());
         kryo.writeClassAndObject(output, object.deviceId());
+        DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
+        // It raises ItemNotFoundException if it failed to find driver
+        Driver driver = driverService.getDriver(object.deviceId());
+        kryo.writeClassAndObject(output, driver.name());
         kryo.writeClassAndObject(output, object.extensionInstruction().serialize());
     }
 
@@ -58,13 +63,14 @@
                                                          Class<Instructions.ExtensionInstructionWrapper> type) {
         ExtensionTreatmentType exType = (ExtensionTreatmentType) kryo.readClassAndObject(input);
         DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
+        String driverName = (String) kryo.readClassAndObject(input);
         DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
         byte[] bytes = (byte[]) kryo.readClassAndObject(input);
         ExtensionTreatment instruction;
 
         try {
             DriverHandler handler = new DefaultDriverHandler(
-                    new DefaultDriverData(driverService.getDriver(deviceId), deviceId));
+                    new DefaultDriverData(driverService.getDriver(driverName), deviceId));
             ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class);
             instruction = resolver.getExtensionInstruction(exType);
             instruction.deserialize(bytes);