[ 
https://issues.apache.org/jira/browse/CSV-300?focusedWorklogId=799496&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-799496
 ]

ASF GitHub Bot logged work on CSV-300:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 09/Aug/22 20:20
            Start Date: 09/Aug/22 20:20
    Worklog Time Spent: 10m 
      Work Description: kinow commented on code in PR #249:
URL: https://github.com/apache/commons-csv/pull/249#discussion_r941764572


##########
src/main/java/org/apache/commons/csv/CSVRecord.java:
##########
@@ -298,13 +299,14 @@ public Stream<String> stream() {
     }
 
     /**
-     * Converts the values to a List.
+     * Converts the values to a new {@code List}.<br>
+     * Modifications to the list do not alter this record.
      *
-     * @return a new List
+     * @return a new {@code List}
      * @since 1.9.0
      */
     public List<String> toList() {
-        return Arrays.asList(values);
+        return new ArrayList<>(Arrays.asList(values));

Review Comment:
   (Also needs to update the javadocs as mentioned in the JIRA comment too, and 
needs unit tests as pointed below by @garydgregory :+1: )





Issue Time Tracking
-------------------

    Worklog Id:     (was: 799496)
    Time Spent: 50m  (was: 40m)

> CSVRecord.toList() gives write access to private values array
> -------------------------------------------------------------
>
>                 Key: CSV-300
>                 URL: https://issues.apache.org/jira/browse/CSV-300
>             Project: Commons CSV
>          Issue Type: Bug
>    Affects Versions: 1.9.0
>            Reporter: Markus Spann
>            Priority: Trivial
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> {{CSVRecord.toList()}} converts the values to a list by calling 
> {{Arrays.asList}} which writes to the private array in calls to 
> {{{}Arrays.ArrayList.set(int, E){}}}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to