Suppress issues found by FindBugs: EI_EXPOSE_REP and EI_EXPOSE_REP2
http://findbugs.sourceforge.net/bugDescriptions.html#EI_EXPOSE_REP
http://findbugs.sourceforge.net/bugDescriptions.html#EI_EXPOSE_REP2
A proper fix for EI_EXPOSE_REP would require eventually to return a copy of an
internal object.
A proper fix for EI_EXPOSE_REP2 would require eventually to store a copy of the
provided object-argument.
However, the performance implication of creating the extra copies is not clear,
hence for the time being all those issues are suppressed by using the following
statements:
@SuppressFBWarnings(value = "EI_EXPOSE_REP",
justification = "TODO: Return a copy of the object?")
@SuppressFBWarnings(value = "EI_EXPOSE_REP2",
justification = "TODO: Store a copy of the object?")
Those suppressed warnings should be re-evaluated and addressed on case-by-case, e.g.
create object copies as appropriate.
Change-Id: I2df00242876e6c185d9fc098b15217138a324a8d
diff --git a/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZMultiEntryOperation.java b/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZMultiEntryOperation.java
index db354eb..0a7fc5e 100644
--- a/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZMultiEntryOperation.java
+++ b/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZMultiEntryOperation.java
@@ -4,6 +4,8 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
import net.onrc.onos.core.datastore.IKVTableID;
import net.onrc.onos.core.datastore.IMultiEntryOperation;
import net.onrc.onos.core.datastore.hazelcast.HZTable.VersionedValue;
@@ -33,6 +35,8 @@
* @param key
* @param operation
*/
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP2",
+ justification = "TODO: Store a copy of the object?")
public HZMultiEntryOperation(final HZTable table, final byte[] key, final OPERATION operation) {
this.table = table;
this.key = key;
@@ -52,6 +56,8 @@
* @param version
* @param operation
*/
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP2",
+ justification = "TODO: Store a copy of the object?")
public HZMultiEntryOperation(final HZTable table, final byte[] key, final byte[] value, final long version, final OPERATION operation) {
this.table = table;
this.key = key;
@@ -81,6 +87,8 @@
}
@Override
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP",
+ justification = "TODO: Return a copy of the object?")
public byte[] getKey() {
return key;
}