[
https://issues.apache.org/jira/browse/CSV-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13616234#comment-13616234
]
Gary Gregory commented on CSV-96:
---------------------------------
@Emmanuel Point taken, but I would be more concerned about code that runs once
per column value, instead of once per record.
The code above causes this test to fail:
org.apache.commons.csv.CSVParserTest.testMappedButNotSetAsOutlook2007ContactExport()
so we can forget about this kind of test unless we want to add a strict vs.
lenient option.
I'm inclined to leave the code as is for now. Adding a check on column access
would mean that in most cases, when the data is correctly formatted, you'd pay
for the size check twice, once in our code to throw an exception and another in
the JRE/JVM when the array is accessed (which is imagine is very fast).
> 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