Use ArrayUtils.clone() to clone byte[] arrays.
Using ArrayUtils.clone() simplifies the code, because it handles
null arrays.
Change-Id: I434856c5a9713759a642dd32a7ca8dfafb136047
diff --git a/src/main/java/net/onrc/onos/core/packet/LLDPTLV.java b/src/main/java/net/onrc/onos/core/packet/LLDPTLV.java
index 8de0d8a..d41b088 100644
--- a/src/main/java/net/onrc/onos/core/packet/LLDPTLV.java
+++ b/src/main/java/net/onrc/onos/core/packet/LLDPTLV.java
@@ -20,6 +20,8 @@
import java.nio.ByteBuffer;
import java.util.Arrays;
+import org.apache.commons.lang.ArrayUtils;
+
/**
* @author David Erickson (daviderickson@cs.stanford.edu)
*/
@@ -62,21 +64,14 @@
* @return the value
*/
public byte[] getValue() {
- if (this.value == null) {
- return null;
- }
- return this.value.clone();
+ return ArrayUtils.clone(this.value);
}
/**
* @param value the value to set
*/
public LLDPTLV setValue(byte[] value) {
- if (value == null) {
- this.value = null;
- } else {
- this.value = value.clone();
- }
+ this.value = ArrayUtils.clone(value);
return this;
}