Skip to content

Commit f66a839

Browse files
committed
CSV-216: Avoid Arrays.copyOf()
as .clone() will do -- at least until someone tries to do .withValue(x) in an out-of-range column
1 parent 637ad2d commit f66a839

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/org/apache/commons/csv/CSVRecord.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public final boolean hasComment() {
199199
public final CSVRecord immutable() {
200200
if (isMutable()) {
201201
// Subclass is probably CSVMutableRecord, freeze values
202-
String[] frozenValue = Arrays.copyOf(values, values.length);
202+
String[] frozenValue = values.clone();
203203
return new CSVRecord(frozenValue, mapping, comment, recordNumber, characterPosition);
204204
} else {
205205
return this;
@@ -260,7 +260,7 @@ public final CSVRecord mutable() {
260260
if (isMutable()) {
261261
return this;
262262
}
263-
String[] newValues = Arrays.copyOf(values, values.length);
263+
String[] newValues = values.clone();
264264
return new CSVMutableRecord(newValues, mapping, comment, recordNumber, characterPosition);
265265
}
266266

0 commit comments

Comments
 (0)