Merge pull request #266 from mykolaf/delimcheck
Validate input to setDelimiter(String) for empty string
This commit is contained in:
commit
23c39b158e
|
@ -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