Fix some of the suppressed FindBugs warnings: EI_EXPOSE_REP and EI_EXPOSE_REP2

The fix is to copy the data when setting/returning it.
If this becomes a bottleneck, we can revisit the solution.


Change-Id: I7ad345aa8d19a41221b3550dd9d2cfcd08b36fd1
diff --git a/src/main/java/net/onrc/onos/core/packet/TCP.java b/src/main/java/net/onrc/onos/core/packet/TCP.java
index b435d74..def194c 100644
--- a/src/main/java/net/onrc/onos/core/packet/TCP.java
+++ b/src/main/java/net/onrc/onos/core/packet/TCP.java
@@ -20,8 +20,6 @@
 import java.nio.ByteBuffer;
 import java.util.Arrays;
 
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
 /**
  * @author shudong.zhou@bigswitch.com
  */
@@ -143,17 +141,21 @@
         return this;
     }
 
-    @SuppressFBWarnings(value = "EI_EXPOSE_REP",
-                        justification = "TODO: Return a copy of the object?")
     public byte[] getOptions() {
-        return this.options;
+        if (this.options == null) {
+            return null;
+        }
+        return this.options.clone();
     }
 
-    @SuppressFBWarnings(value = "EI_EXPOSE_REP2",
-                        justification = "TODO: Store a copy of the object?")
     public TCP setOptions(final byte[] options) {
-        this.options = options;
-        this.dataOffset = (byte) ((20 + options.length + 3) >> 2);
+        if (options == null) {
+            this.options = null;
+            this.dataOffset = 0;
+        } else {
+            this.options = options.clone();
+            this.dataOffset = (byte) ((20 + options.length + 3) >> 2);
+        }
         return this;
     }