[CSV-106] CSVFormat.format always append null.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1577011 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bf8f23c310
commit
73cc5246cf
|
@ -321,7 +321,10 @@ public final class CSVPrinter implements Flushable, Closeable {
|
|||
* If an I/O error occurs
|
||||
*/
|
||||
public void println() throws IOException {
|
||||
out.append(format.getRecordSeparator());
|
||||
final String recordSeparator = format.getRecordSeparator();
|
||||
if (recordSeparator != null) {
|
||||
out.append(recordSeparator);
|
||||
}
|
||||
newRecord = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class CSVFormatTest {
|
|||
public void testDelimiterSameAsCommentStartThrowsException() {
|
||||
CSVFormat.DEFAULT.withDelimiter('!').withCommentStart('!').validate();
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testDelimiterSameAsEscapeThrowsException() {
|
||||
CSVFormat.DEFAULT.withDelimiter('!').withEscape('!').validate();
|
||||
|
@ -229,6 +229,14 @@ public class CSVFormatTest {
|
|||
assertNotSame(formatWithHeader.getHeader(), headerCopy);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullRecordSeparatorCsv106() {
|
||||
final CSVFormat format = CSVFormat.newFormat(';').withSkipHeaderRecord(true).withHeader("H1", "H2");
|
||||
final String formatStr = format.format("A", "B");
|
||||
assertNotNull(formatStr);
|
||||
assertFalse(formatStr.endsWith("null"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testQuoteCharSameAsCommentStartThrowsException() {
|
||||
CSVFormat.DEFAULT.withQuoteChar('!').withCommentStart('!').validate();
|
||||
|
|
Loading…
Reference in New Issue