File tree Expand file tree Collapse file tree
main/java/org/apache/commons/csv
test/java/org/apache/commons/csv Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -321,7 +321,10 @@ public void printComment(final String comment) throws IOException {
321321 * If an I/O error occurs
322322 */
323323 public void println () throws IOException {
324- out .append (format .getRecordSeparator ());
324+ final String recordSeparator = format .getRecordSeparator ();
325+ if (recordSeparator != null ) {
326+ out .append (recordSeparator );
327+ }
325328 newRecord = true ;
326329 }
327330
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ private static CSVFormat copy(final CSVFormat format) {
5555 public void testDelimiterSameAsCommentStartThrowsException () {
5656 CSVFormat .DEFAULT .withDelimiter ('!' ).withCommentStart ('!' ).validate ();
5757 }
58-
58+
5959 @ Test (expected = IllegalStateException .class )
6060 public void testDelimiterSameAsEscapeThrowsException () {
6161 CSVFormat .DEFAULT .withDelimiter ('!' ).withEscape ('!' ).validate ();
@@ -229,6 +229,14 @@ public void testGetHeader() throws Exception {
229229 assertNotSame (formatWithHeader .getHeader (), headerCopy );
230230 }
231231
232+ @ Test
233+ public void testNullRecordSeparatorCsv106 () {
234+ final CSVFormat format = CSVFormat .newFormat (';' ).withSkipHeaderRecord (true ).withHeader ("H1" , "H2" );
235+ final String formatStr = format .format ("A" , "B" );
236+ assertNotNull (formatStr );
237+ assertFalse (formatStr .endsWith ("null" ));
238+ }
239+
232240 @ Test (expected = IllegalStateException .class )
233241 public void testQuoteCharSameAsCommentStartThrowsException () {
234242 CSVFormat .DEFAULT .withQuoteChar ('!' ).withCommentStart ('!' ).validate ();
You can’t perform that action at this time.
0 commit comments