I did not see an anwser anywhere about this specific Sonar violation in the case of an array of an array.
Sonar Violation: Security - Array is stored directly
Code with problem :
public void setData(String[][] data) {
if(data == null) {
this.data = new String[0][];
} else {
String[][] dataCopy = new String[data.length][];
System.arraycopy(data, 0, dataCopy, 0, data.length);
this.data = dataCopy;
}
I cannot used the following solution because of my java version :
public void setData(String[][] data) {
if(data == null) {
this.data = new String[0][0];
} else {
this.data = Arrays.copyOf(data, data.length);
}
}
Any suggestions to solve this issue ?