You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Benedikt Ritter (JIRA)" <ji...@apache.org> on 2013/03/20 21:23:16 UTC

[jira] [Commented] (CSV-96) CSVRecord does not verify that the length of the header mapping matches the number of values

    [ https://issues.apache.org/jira/browse/CSV-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13608135#comment-13608135 ] 

Benedikt Ritter commented on CSV-96:
------------------------------------

I'm not sure if CSVRecord's ctor is the right place for checking if the header mapping length is correct. This may lead to a lot of over head because everytime a CSVRecord is created we would have to do something like:

{code}
if(mappings != null && mapping.size() != values.length) {
   throw Exception
}
{code}

For very big files, this may be an issue. Would be better to just test this when the first record is created by the parser.
                
> CSVRecord does not verify that the length of the header mapping matches the number of values
> --------------------------------------------------------------------------------------------
>
>                 Key: CSV-96
>                 URL: https://issues.apache.org/jira/browse/CSV-96
>             Project: Commons CSV
>          Issue Type: Bug
>          Components: Parser
>    Affects Versions: 1.0
>            Reporter: Benedikt Ritter
>             Fix For: 1.0
>
>
> CSVRecord does not verify that the size of the header mapping matches the number of values. The following test will produce a ArrayOutOfBoundsException:
> {code}
> @Test
> public void testInvalidHeaderTooLong() throws Exception {
>    final CSVParser parser = new CSVParser("a,b", CSVFormat.newBuilder().withHeader("A", "B", "C").build());
>    final CSVRecord record = parser.iterator().next();
>    record.get("C");
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira