Fix EI_EXPOSE_REP family issue by copying.
Note: Variables which may be valid to be null uses ArrayUtils.clone()
Change-Id: I6a13dfd66753847de306d50bbdf32e724d896c56
diff --git a/src/main/java/net/onrc/onos/core/datastore/utils/KVObject.java b/src/main/java/net/onrc/onos/core/datastore/utils/KVObject.java
index 078c82d..94f509f 100644
--- a/src/main/java/net/onrc/onos/core/datastore/utils/KVObject.java
+++ b/src/main/java/net/onrc/onos/core/datastore/utils/KVObject.java
@@ -6,8 +6,6 @@
import java.util.List;
import java.util.Map;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
import net.onrc.onos.core.datastore.DataStoreClient;
import net.onrc.onos.core.datastore.IKVClient;
import net.onrc.onos.core.datastore.IKVTable;
@@ -64,8 +62,6 @@
this(table, key, null, table.getVersionNonexistant());
}
- @SuppressFBWarnings(value = "EI_EXPOSE_REP2",
- justification = "TODO: Store a copy of the object?")
public KVObject(final IKVTable table, final byte[] key, final byte[] value, final long version) {
if (table == null) {
throw new IllegalArgumentException("table cannot be null");
@@ -74,7 +70,7 @@
throw new IllegalArgumentException("key cannot be null");
}
this.table = table;
- this.key = key;
+ this.key = key.clone();
this.version = version;
this.propertyMap = new HashMap<Object, Object>();
@@ -97,10 +93,8 @@
return table.getTableId();
}
- @SuppressFBWarnings(value = "EI_EXPOSE_REP",
- justification = "TODO: Return a copy of the object?")
public byte[] getKey() {
- return key;
+ return key.clone();
}
public long getVersion() {