Not sure what sonar is thinking, but defensive shallow copying with clone() should work fine for arrays, like Arrays.copyOf and System.arrayCopy() .
On the other hand, since you are already calling the array as a list: selectedObjectsList , you can also make it an actual list and reorganize the bit:
public final void setSelectedSchedules(List<ScheduleDTO> selectedSchedules) { this.selectedSchedules = selectedSchedules != null ? new ArrayList<ScheduleDTO>(selectedSchedules) : null; }
Jukka source share