Skip to content

Commit f25f3d5

Browse files
authored
Merge branch 'master' into fix/CSV-329_trackbytes_supplementary_delimiter
2 parents 1d89cd5 + d8e1242 commit f25f3d5

6 files changed

Lines changed: 14 additions & 5 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
steps:
4848
- name: Checkout repository
49-
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
49+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
5050
with:
5151
persist-credentials: false
5252
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5

.github/workflows/dependency-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ jobs:
2626
runs-on: ubuntu-latest
2727
steps:
2828
- name: 'Checkout Repository'
29-
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
29+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
3030
- name: 'Dependency Review PR'
3131
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
experimental: true
4444

4545
steps:
46-
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
46+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
4747
with:
4848
persist-credentials: false
4949
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<action type="fix" dev="ggregory" due-to="Ruiqi Dong, Gary Gregory" issue="CSV-326">CSVPrinter Reader printing with quote and escape can emit CSV that its parser cannot read back.</action>
5555
<action type="fix" dev="ggregory" due-to="Ruiqi Dong, Gary Gregory" issue="CSV-327">CSVParser applies maxRows to record numbers instead of rows produced when setRecordNumber(...) is used.</action>
5656
<action type="fix" dev="ggregory" due-to="Ruiqi Dong, Gary Gregory" issue="CSV-329">CSVParser with trackBytes enabled throws on multi-character delimiters containing supplementary Unicode characters.</action>
57+
<action type="fix" dev="ggregory" due-to="Ruiqi Dong, Gary Gregory" issue="CSV-328">CSVFormat.Builder.setNullString(String) can build an invalid quoted null string after setQuote(null).</action>
5758
<action type="fix" dev="ggregory" due-to="OldTruckDriver, Gary Gregory" issue="CSV-326">Escape Reader values with quote and escape (#606).</action>
5859
<action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Clear escape delimiter buffer before peek in Lexer.isEscapeDelimiter() (#608, #611).</action>
5960
<action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Escape quote char in printWithEscapes when QuoteMode is NONE (#609).</action>

src/main/java/org/apache/commons/csv/CSVFormat.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,7 @@ public Builder setMaxRows(final long maxRows) {
780780
*/
781781
public Builder setNullString(final String nullString) {
782782
this.nullString = nullString;
783-
this.quotedNullString = quoteCharacter + nullString + quoteCharacter;
784-
return this;
783+
return setQuotedNullString();
785784
}
786785

787786
/**
@@ -806,6 +805,10 @@ public Builder setQuote(final Character quoteCharacter) {
806805
throw new IllegalArgumentException("The quoteCharacter cannot be a line break");
807806
}
808807
this.quoteCharacter = quoteCharacter;
808+
return setQuotedNullString();
809+
}
810+
811+
private Builder setQuotedNullString() {
809812
final Character quote = quoteCharacter != null ? quoteCharacter : Constants.DOUBLE_QUOTE_CHAR;
810813
this.quotedNullString = quote + nullString + quote;
811814
return this;

src/test/java/org/apache/commons/csv/CSVFormatTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,11 @@ void testQuotedNullStringTracksQuoteCharacter() throws IOException {
10401040
builder.setQuote((Character) null);
10411041
builder.get().print(null, out, true);
10421042
assertEquals("\"NULL\"", out.toString());
1043+
// reset, reverse setter order
1044+
out.setLength(0);
1045+
builder.setNullString(null).setQuote((Character) null).setNullString("NULL");
1046+
builder.get().print(null, out, true);
1047+
assertEquals("\"NULL\"", out.toString());
10431048
}
10441049

10451050
@Test

0 commit comments

Comments
 (0)