attempt to fix buffer underflow
- IMap#get usually returns clone of original value,
but when the type is byte[], it returns the original value.
- During the deserialization process, Kryo temporarily modifies the input buffer,
which may cause problem when multiple threads were reading the same value.
- applying clone only to value deserialization for now,
since it is unlikely that caller will be modifying Map key
Change-Id: I52214ba711b4060663b0e1c451f49bdd1d472ea9
diff --git a/core/store/hz/common/src/main/java/org/onlab/onos/store/common/SMap.java b/core/store/hz/common/src/main/java/org/onlab/onos/store/common/SMap.java
index 93a7b0d..6dd4bfb 100644
--- a/core/store/hz/common/src/main/java/org/onlab/onos/store/common/SMap.java
+++ b/core/store/hz/common/src/main/java/org/onlab/onos/store/common/SMap.java
@@ -492,7 +492,10 @@
}
private V deserializeVal(byte[] val) {
- return serializer.decode(val);
+ if (val == null) {
+ return null;
+ }
+ return serializer.decode(val.clone());
}
private Set<byte[]> serializeKeySet(Set<K> keys) {