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

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

>From a user PoV a meaningful exception should be thrown - so yes this is 
>partly related to which exception should be thrown. This could for example be 
>an IllegalStateException with a message like "Header mapping does not match 
>actual record length."

The question is, if it is sufficient to catch {{ArrayOutOfBoundsException}} and 
throw ISE? What if the header mapping is shorter than the record? IMHO this is 
also an illegal state but it will not be detected by a try-catch-block that 
catches AOOBE.
                
> 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

Reply via email to