[
https://issues.apache.org/jira/browse/CSV-249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16890693#comment-16890693
]
Jelmer Kuperus commented on CSV-249:
------------------------------------
Seems to be a duplicate of an issue from 2016 !!!
Apache spark ships with both .escapa character and quote character set, so is
effectively broken this way
> ArrayIndexOutOfBoundsException when trying to read record written by
> CSVPrinter using CSVParser with same format
> ----------------------------------------------------------------------------------------------------------------
>
> Key: CSV-249
> URL: https://issues.apache.org/jira/browse/CSV-249
> Project: Commons CSV
> Issue Type: Bug
> Components: Parser
> Affects Versions: 1.5, 1.6, 1.7
> Reporter: Jelmer Kuperus
> Priority: Major
>
> The following code will fail with the exception
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 1
> out of bounds for length 1
> {noformat}
> import org.apache.commons.csv.*;
> import java.io.StringReader;
> import java.io.StringWriter;
> import java.util.List;
> public class Poc {
> public static void main(String[] args) throws Exception {
> CSVFormat csvFormat = CSVFormat.DEFAULT
> .withEscape('\\');
> StringWriter stringWriter = new StringWriter();
> CSVPrinter printer = new CSVPrinter(stringWriter, csvFormat);
> printer.printRecord("foo \\", "bar");
> StringReader stringReader = new StringReader(stringWriter.toString());
> CSVParser parser = new CSVParser(stringReader, csvFormat);
> List<CSVRecord> records = parser.getRecords();
> records.forEach(record -> {
> System.out.println(record.get(0));
> System.out.println(record.get(1));
> });
> }
> }{noformat}
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)