[SDFAB-576] Fix serialization of bytesequence

Replicas do not get all the information from the leader
and show weird strings when rendering PiCriterion. This
affects only byte sequence containing ascii string

Change-Id: Id656c2d150294866878175d7d703148739525f95
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/ImmutableByteSequenceSerializer.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/ImmutableByteSequenceSerializer.java
index 1cbd021..9670acd 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/ImmutableByteSequenceSerializer.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/ImmutableByteSequenceSerializer.java
@@ -38,12 +38,14 @@
     @Override
     public void write(Kryo kryo, Output output, ImmutableByteSequence object) {
         byte[] data = object.asArray();
+        output.writeBoolean(object.isAscii());
         output.writeInt(data.length);
         output.write(data);
     }
 
     @Override
     public ImmutableByteSequence read(Kryo kryo, Input input, Class<ImmutableByteSequence> type) {
+        boolean isAscii = input.readBoolean();
         int length = input.readInt();
         byte[] data = new byte[length];
         int bytesRead = input.read(data);
@@ -51,6 +53,10 @@
             throw new IllegalStateException("Byte sequence serializer read expected " + length +
                     " but got " + bytesRead);
         }
+
+        if (isAscii) {
+            return ImmutableByteSequence.copyFrom(new String(data));
+        }
         return ImmutableByteSequence.copyFrom(data);
     }
 }