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/topology/KVDevice.java b/src/main/java/net/onrc/onos/core/datastore/topology/KVDevice.java
index 3c56d2c..9a6d550 100644
--- a/src/main/java/net/onrc/onos/core/datastore/topology/KVDevice.java
+++ b/src/main/java/net/onrc/onos/core/datastore/topology/KVDevice.java
@@ -10,8 +10,6 @@
import java.util.Set;
import java.util.TreeSet;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
import net.onrc.onos.core.datastore.DataStoreClient;
import net.onrc.onos.core.datastore.IKVTable.IKVEntry;
import net.onrc.onos.core.datastore.topology.KVLink.STATUS;
@@ -77,12 +75,10 @@
return mac;
}
- @SuppressFBWarnings(value = "EI_EXPOSE_REP2",
- justification = "TODO: Store a copy of the object?")
public KVDevice(final byte[] mac) {
super(DataStoreClient.getClient().getTable(GLOBAL_DEVICE_TABLE_NAME), getDeviceID(mac));
- this.mac = mac;
+ this.mac = mac.clone();
this.portIds = new TreeSet<>(ByteArrayComparator.BYTEARRAY_COMPARATOR);
this.isPortIdsModified = true;
}
@@ -125,11 +121,8 @@
}
}
- @SuppressFBWarnings(value = "EI_EXPOSE_REP",
- justification = "TODO: Return a copy of the object?")
public byte[] getMac() {
- // TODO may need to clone() to be sure this object will be immutable.
- return mac;
+ return mac.clone();
}
public byte[] getId() {