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/packet/ARP.java b/src/main/java/net/onrc/onos/core/packet/ARP.java
index ae49c4b..e6fcecc 100644
--- a/src/main/java/net/onrc/onos/core/packet/ARP.java
+++ b/src/main/java/net/onrc/onos/core/packet/ARP.java
@@ -20,6 +20,8 @@
import java.nio.ByteBuffer;
import java.util.Arrays;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
/**
* @author David Erickson (daviderickson@cs.stanford.edu)
*/
@@ -121,6 +123,8 @@
/**
* @return the senderHardwareAddress
*/
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP",
+ justification = "TODO: Return a copy of the object?")
public byte[] getSenderHardwareAddress() {
return senderHardwareAddress;
}
@@ -128,6 +132,8 @@
/**
* @param senderHardwareAddress the senderHardwareAddress to set
*/
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP2",
+ justification = "TODO: Store a copy of the object?")
public ARP setSenderHardwareAddress(byte[] senderHardwareAddress) {
this.senderHardwareAddress = senderHardwareAddress;
return this;
@@ -136,6 +142,8 @@
/**
* @return the senderProtocolAddress
*/
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP",
+ justification = "TODO: Return a copy of the object?")
public byte[] getSenderProtocolAddress() {
return senderProtocolAddress;
}
@@ -143,6 +151,8 @@
/**
* @param senderProtocolAddress the senderProtocolAddress to set
*/
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP2",
+ justification = "TODO: Store a copy of the object?")
public ARP setSenderProtocolAddress(byte[] senderProtocolAddress) {
this.senderProtocolAddress = senderProtocolAddress;
return this;
@@ -156,6 +166,8 @@
/**
* @return the targetHardwareAddress
*/
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP",
+ justification = "TODO: Return a copy of the object?")
public byte[] getTargetHardwareAddress() {
return targetHardwareAddress;
}
@@ -163,6 +175,8 @@
/**
* @param targetHardwareAddress the targetHardwareAddress to set
*/
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP2",
+ justification = "TODO: Store a copy of the object?")
public ARP setTargetHardwareAddress(byte[] targetHardwareAddress) {
this.targetHardwareAddress = targetHardwareAddress;
return this;
@@ -171,6 +185,8 @@
/**
* @return the targetProtocolAddress
*/
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP",
+ justification = "TODO: Return a copy of the object?")
public byte[] getTargetProtocolAddress() {
return targetProtocolAddress;
}
@@ -195,6 +211,8 @@
/**
* @param targetProtocolAddress the targetProtocolAddress to set
*/
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP2",
+ justification = "TODO: Store a copy of the object?")
public ARP setTargetProtocolAddress(byte[] targetProtocolAddress) {
this.targetProtocolAddress = targetProtocolAddress;
return this;