@@ -1562,6 +1562,35 @@ public void testTrim() throws Exception {
15621562 assertEquals (3 , record .size ());
15631563 }}
15641564
1565+ @ Test
1566+ public void testParsingPrintedEmptyFirstColumn () throws Exception {
1567+ Exception firstException = null ;
1568+ for (CSVFormat .Predefined format : CSVFormat .Predefined .values ()) {
1569+ try {
1570+ StringWriter buf = new StringWriter ();
1571+ try (CSVPrinter printer = new CSVPrinter (buf , format .getFormat ())) {
1572+ printer .printRecord ("a" , "b" ); // header
1573+ printer .printRecord ("" , "x" ); // empty first column
1574+ }
1575+ try (CSVParser csvRecords = new CSVParser (new StringReader (buf .toString ()), format .getFormat ().builder ().setHeader ().build ())) {
1576+ for (CSVRecord csvRecord : csvRecords ) {
1577+ assertNotNull (csvRecord );
1578+ }
1579+ }
1580+ } catch (Exception | Error e ) {
1581+ Exception detailedException = new RuntimeException ("format: " + format , e );
1582+ if (firstException == null ) {
1583+ firstException = detailedException ;
1584+ } else {
1585+ firstException .addSuppressed (detailedException );
1586+ }
1587+ }
1588+ }
1589+
1590+ if (firstException != null )
1591+ throw firstException ;
1592+ }
1593+
15651594 private void validateLineNumbers (final String lineSeparator ) throws IOException {
15661595 try (final CSVParser parser = CSVParser .parse ("a" + lineSeparator + "b" + lineSeparator + "c" , CSVFormat .DEFAULT .withRecordSeparator (lineSeparator ))) {
15671596 assertEquals (0 , parser .getCurrentLineNumber ());
0 commit comments