Skip to content

Commit 10ebc1e

Browse files
committed
after bug fix 5
2 parents b7a36d2 + 73cc524 commit 10ebc1e

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/main/java/org/apache/commons/csv/CSVPrinter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff 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

src/test/java/org/apache/commons/csv/CSVFormatTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)