Skip to content

[CSV-328] Fix quoted null string after disabling quote#612

Merged
garydgregory merged 1 commit into
apache:masterfrom
OldTruckDriver:fix/CSV-328_quoted_null_string_order
Jun 18, 2026
Merged

[CSV-328] Fix quoted null string after disabling quote#612
garydgregory merged 1 commit into
apache:masterfrom
OldTruckDriver:fix/CSV-328_quoted_null_string_order

Conversation

@OldTruckDriver

Copy link
Copy Markdown
Contributor

[CSV-328] Fix quoted null string after disabling quote

CSVFormat.Builder#setNullString(String) rebuilt quotedNullString by concatenating the nullable quoteCharacter field directly. When setQuote(null) was called before setNullString("NULL"), QuoteMode.ALL printed null as nullNULLnull instead of "NULL".

This change makes setNullString(String) and setQuote(Character) use the same quoted-null-string update logic, preserving the existing fallback to the default double quote when the quote character is disabled.

Tests cover both setter orders for setNullString("NULL") and setQuote(null).

Tests run:

  • mvn -q -Dtest=org.apache.commons.csv.CSVFormatTest#testQuotedNullStringTracksQuoteCharacter test
  • mvn -q -Dtest=org.apache.commons.csv.CSVFormatTest test
  • mvn -q

@garydgregory garydgregory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @OldTruckDriver
Thank you for the PR, please see my comment.

return this;
}

private void setQuotedNullString() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OldTruckDriver
Please keep and use the fluent style.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Made setQuotedNullString() return the Builder and used return in the setters. Thanks

setNullString(String) rebuilt quotedNullString by concatenating the nullable
quoteCharacter field directly, so calling setQuote(null) before setNullString(...)
produced a literal "nullNULLnull". Extract a shared setQuotedNullString() helper
that applies the default-quote fallback, so both builder orders produce the same state.

Reviewed-by: OpenAI Codex
Reviewed-by: Anthropic Claude Code
@OldTruckDriver OldTruckDriver force-pushed the fix/CSV-328_quoted_null_string_order branch from ce08e8c to a6ee67e Compare June 18, 2026 16:57
@garydgregory garydgregory merged commit 28d8bfb into apache:master Jun 18, 2026
16 checks passed
@garydgregory

garydgregory commented Jun 18, 2026

Copy link
Copy Markdown
Member

Jira ticket is https://issues.apache.org/jira/browse/CSV-328
Merged 🚀 Thank you @OldTruckDriver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants