File tree Expand file tree Collapse file tree
main/java/org/apache/commons/csv
test/java/org/apache/commons/csv Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -346,6 +346,9 @@ public Builder setDelimiter(final String delimiter) {
346346 if (containsLineBreak (delimiter )) {
347347 throw new IllegalArgumentException ("The delimiter cannot be a line break" );
348348 }
349+ if (delimiter .isEmpty ()) {
350+ throw new IllegalArgumentException ("The delimiter cannot be empty" );
351+ }
349352 this .delimiter = delimiter ;
350353 return this ;
351354 }
Original file line number Diff line number Diff line change @@ -1569,4 +1569,9 @@ public void testWithSystemRecordSeparator() {
15691569 final CSVFormat formatWithRecordSeparator = CSVFormat .DEFAULT .withSystemRecordSeparator ();
15701570 assertEquals (System .lineSeparator (), formatWithRecordSeparator .getRecordSeparator ());
15711571 }
1572+
1573+ @ Test
1574+ public void testDelimiterEmptyStringThrowsException1 () {
1575+ assertThrows (IllegalArgumentException .class , () -> CSVFormat .DEFAULT .builder ().setDelimiter ("" ).build ());
1576+ }
15721577}
You can’t perform that action at this time.
0 commit comments