[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
|
* If an I/O error occurs
|
||||||
*/
|
*/
|
||||||
public void println() throws IOException {
|
public void println() throws IOException {
|
||||||
out.append(format.getRecordSeparator());
|
final String recordSeparator = format.getRecordSeparator();
|
||||||
|
if (recordSeparator != null) {
|
||||||
|
out.append(recordSeparator);
|
||||||
|
}
|
||||||
newRecord = true;
|
newRecord = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,6 +229,14 @@ public class CSVFormatTest {
|
||||||
assertNotSame(formatWithHeader.getHeader(), headerCopy);
|
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)
|
@Test(expected = IllegalStateException.class)
|
||||||
public void testQuoteCharSameAsCommentStartThrowsException() {
|
public void testQuoteCharSameAsCommentStartThrowsException() {
|
||||||
CSVFormat.DEFAULT.withQuoteChar('!').withCommentStart('!').validate();
|
CSVFormat.DEFAULT.withQuoteChar('!').withCommentStart('!').validate();
|
||||||
|
|
Loading…
Reference in New Issue