Commons CSV
  1. Commons CSV
  2. CSV-111

CSVRecord.toMap() fails if row length shorter than header length

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0
    • Component/s: Parser
    • Labels:
      None

      Description

      Similar to CSV-96, if .toMap() is called on a record that has fewer fields than we have header columns we'll get an ArrayOutOfBoundsException.

      @Test
      public void testToMapWhenHeaderTooLong() throws Exception {
         final CSVParser parser = new CSVParser("a,b", CSVFormat.newBuilder().withHeader("A", "B", "C").build());
         final CSVRecord record = parser.iterator().next();
         record.toMap();
      }
      

        Activity

        Hide
        Gary Gregory added a comment -
        commit -m "[CSV-111] CSVRecord.toMap() fails if row length shorter than header length." C:/vcs/svn/apache/commons/trunks-proper/csv/src/main/java/org/apache/commons/csv/CSVRecord.java C:/vcs/svn/apache/commons/trunks-proper/csv/src/test/java/org/apache/commons/csv/CSVRecordTest.java
            Sending        C:/vcs/svn/apache/commons/trunks-proper/csv/src/main/java/org/apache/commons/csv/CSVRecord.java
            Sending        C:/vcs/svn/apache/commons/trunks-proper/csv/src/test/java/org/apache/commons/csv/CSVRecordTest.java
            Transmitting file data ...
            Committed revision 1589281.
        
        Show
        Gary Gregory added a comment - commit -m "[CSV-111] CSVRecord.toMap() fails if row length shorter than header length." C:/vcs/svn/apache/commons/trunks-proper/csv/src/main/java/org/apache/commons/csv/CSVRecord.java C:/vcs/svn/apache/commons/trunks-proper/csv/src/test/java/org/apache/commons/csv/CSVRecordTest.java Sending C:/vcs/svn/apache/commons/trunks-proper/csv/src/main/java/org/apache/commons/csv/CSVRecord.java Sending C:/vcs/svn/apache/commons/trunks-proper/csv/src/test/java/org/apache/commons/csv/CSVRecordTest.java Transmitting file data ... Committed revision 1589281.

          People

          • Assignee:
            Unassigned
            Reporter:
            Rupert Wood
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development