Fix ONOS-815: register Optional class to Kryo
Change-Id: Iab40b3c02b54634452006bbaae18e450d91de347
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
index b36595d..f843cc4 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
@@ -23,6 +23,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
+import java.util.Optional;
import org.onosproject.cluster.ControllerNode;
import org.onosproject.cluster.DefaultControllerNode;
@@ -156,6 +157,7 @@
.register(Collections.singletonList(1).getClass())
.register(Duration.class)
.register(Collections.emptySet().getClass())
+ .register(Optional.class)
.build();
/**
diff --git a/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java b/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java
index c7fdf24..a2ceb39 100644
--- a/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java
+++ b/core/store/serializers/src/test/java/org/onosproject/store/serializers/KryoSerializerTest.java
@@ -42,7 +42,12 @@
import org.onosproject.net.LinkKey;
import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.flow.DefaultFlowRule;
+import org.onosproject.net.flow.DefaultTrafficSelector;
+import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.FlowId;
+import org.onosproject.net.flow.FlowRule;
+import org.onosproject.net.flow.FlowRuleBatchEntry;
import org.onosproject.net.intent.IntentId;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.resource.Bandwidth;
@@ -198,6 +203,22 @@
}
@Test
+ public void testFlowRuleBatchEntry() {
+ final FlowRule rule1 =
+ new DefaultFlowRule(DID1, DefaultTrafficSelector.builder().build(),
+ DefaultTrafficTreatment.builder().build(), 0, 0, 0, true);
+ final FlowRule rule2 =
+ new DefaultFlowRule(DID1, DefaultTrafficSelector.builder().build(),
+ DefaultTrafficTreatment.builder().build(), 0, 0, 0, true);
+ final FlowRuleBatchEntry entry1 =
+ new FlowRuleBatchEntry(FlowRuleBatchEntry.FlowRuleOperation.ADD, rule1);
+ final FlowRuleBatchEntry entry2 =
+ new FlowRuleBatchEntry(FlowRuleBatchEntry.FlowRuleOperation.ADD, rule2);
+
+ testSerializedEquals(ImmutableList.of(entry1, entry2));
+ }
+
+ @Test
public void testIpPrefix() {
testSerializedEquals(IpPrefix.valueOf("192.168.0.1/24"));
}