Check setDelimiter() for empty string
Signed-off-by: Mykola Faryma <m.faryma@partner.samsung.com>
This commit is contained in:
parent
048d507de9
commit
1da75703a4
|
@ -346,6 +346,9 @@ public final class CSVFormat implements Serializable {
|
|||
if (containsLineBreak(delimiter)) {
|
||||
throw new IllegalArgumentException("The delimiter cannot be a line break");
|
||||
}
|
||||
if (delimiter.isEmpty()) {
|
||||
throw new IllegalArgumentException("The delimiter cannot be empty");
|
||||
}
|
||||
this.delimiter = delimiter;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1569,4 +1569,9 @@ public class CSVFormatTest {
|
|||
final CSVFormat formatWithRecordSeparator = CSVFormat.DEFAULT.withSystemRecordSeparator();
|
||||
assertEquals(System.lineSeparator(), formatWithRecordSeparator.getRecordSeparator());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelimiterEmptyStringThrowsException1() {
|
||||
assertThrows(IllegalArgumentException.class, () -> CSVFormat.DEFAULT.builder().setDelimiter("").build());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue