java_gen: Return copies of byte arrays in getBytes LOXI-58
The getBytes() methods of various classes in openflow.types were
returning and caching instances of byte[], which is mutable. They
now return clone()'d instances.
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
index a9da637..73b1a7d 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
@@ -119,7 +119,7 @@
return rawValue;
}
- volatile byte[] bytesCache = null;
+ private volatile byte[] bytesCache = null;
public byte[] getBytes() {
if (bytesCache == null) {
@@ -133,7 +133,7 @@
}
}
}
- return bytesCache;
+ return bytesCache.clone();
}
@Override
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
index 4e7b856..853bb65 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
@@ -201,7 +201,7 @@
return new IPv6Address(raw1, raw2);
}
- volatile byte[] bytesCache = null;
+ private volatile byte[] bytesCache = null;
public byte[] getBytes() {
if (bytesCache == null) {
@@ -228,7 +228,7 @@
}
}
}
- return bytesCache;
+ return bytesCache.clone();
}
@Override
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/MacAddress.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/MacAddress.java
index 27d5b66..48a4faf 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/MacAddress.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/MacAddress.java
@@ -79,7 +79,7 @@
return MacAddress.of(raw);
}
- volatile byte[] bytesCache = null;
+ private volatile byte[] bytesCache = null;
public byte[] getBytes() {
if (bytesCache == null) {
@@ -95,7 +95,7 @@
}
}
}
- return bytesCache;
+ return bytesCache.clone();
}
/**
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFVlanVidMatch.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFVlanVidMatch.java
index fddaa5d..51f3776 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFVlanVidMatch.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFVlanVidMatch.java
@@ -143,7 +143,7 @@
}
- volatile byte[] bytesCache = null;
+ private volatile byte[] bytesCache = null;
public byte[] getBytes() {
if (bytesCache == null) {
@@ -155,7 +155,7 @@
}
}
}
- return bytesCache;
+ return bytesCache.clone();
}
public void write2Bytes(ChannelBuffer c) {
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanVid.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanVid.java
index 8337eb6..86633a5 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanVid.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanVid.java
@@ -67,7 +67,7 @@
return LENGTH;
}
- volatile byte[] bytesCache = null;
+ private volatile byte[] bytesCache = null;
public byte[] getBytes() {
if (bytesCache == null) {
@@ -79,7 +79,7 @@
}
}
}
- return bytesCache;
+ return bytesCache.clone();
}
public void write2Bytes(ChannelBuffer c) {