BugFix: Add default constructor to OnosInstanceId
- Adding default constructor to make it Kryo deserializable.
Change-Id: Ic17926d88b30853620ab0c1c8d18f053793771c0
diff --git a/src/main/java/net/onrc/onos/core/util/OnosInstanceId.java b/src/main/java/net/onrc/onos/core/util/OnosInstanceId.java
index 34e370a..61b0751 100644
--- a/src/main/java/net/onrc/onos/core/util/OnosInstanceId.java
+++ b/src/main/java/net/onrc/onos/core/util/OnosInstanceId.java
@@ -12,6 +12,14 @@
private final String id;
/**
+ * Default constructor for serializer.
+ */
+ @Deprecated
+ protected OnosInstanceId() {
+ id = "(should never see this)";
+ }
+
+ /**
* Constructor from a string value.
*
* @param id the value to use.
diff --git a/src/test/java/net/onrc/onos/core/util/serializers/KryoFactoryTest.java b/src/test/java/net/onrc/onos/core/util/serializers/KryoFactoryTest.java
index 95b1ca2..9431cfe 100644
--- a/src/test/java/net/onrc/onos/core/util/serializers/KryoFactoryTest.java
+++ b/src/test/java/net/onrc/onos/core/util/serializers/KryoFactoryTest.java
@@ -16,6 +16,7 @@
import net.onrc.onos.core.topology.TopologyEvent;
import net.onrc.onos.core.topology.SwitchEvent;
import net.onrc.onos.core.util.Dpid;
+import net.onrc.onos.core.util.OnosInstanceId;
import net.onrc.onos.core.util.PortNumber;
import net.onrc.onos.core.util.SwitchPort;
@@ -229,6 +230,15 @@
assertEquals(27, result.size);
}
+ { // CHECKSTYLE IGNORE THIS LINE
+ OnosInstanceId id = new OnosInstanceId("Some_Instance_Name");
+
+ Result result = benchType(id, EqualityCheck.EQUALS);
+ results.add(result);
+ // update me if serialized form is expected to change
+ assertEquals(21, result.size);
+ }
+
// TODO Add registered classes we still use.