Pass normalized separator in CsvSchema.withArrayElementSeparator (avoid null state / NPE) - #710
Open
uttam12331 wants to merge 1 commit into
Open
Conversation
Member
|
Sounds good! CLA needed if not sent before -- adding release notes would be great too. But one question/suggestion: might make sense to target 2.21 as backport (2.21 latest LTS version)? |
…state `CsvSchema.withArrayElementSeparator(String)` normalizes a null argument to "" in the local `sep` and uses it for the equality check, but then passes the raw `separator` to the copy constructor, so `withArrayElementSeparator(null)` leaves `_arrayElementSeparator` null. `hasArrayElementSeparator()` then NPEs on `!_arrayElementSeparator.isEmpty()`, as does a later `withArrayElementSeparator` on `_arrayElementSeparator.equals(sep)`. Pass the already-normalized `sep`, add a regression test, and add release notes.
uttam12331
force-pushed
the
fix/with-array-element-separator-null
branch
from
August 4, 2026 05:37
e31a3b8 to
3a43684
Compare
Author
|
Thanks @cowtowncoder! Retargeted this to |
Author
|
I've filled and signed the 2026 ICLA ( |
Member
|
@uttam12331 email to "cla" at fasterxml dot com. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CsvSchema.withArrayElementSeparator(String separator)normalizes anullargument to""in the localsepand usessepfor the equality check, but then passes the rawseparatorto the copy constructor:The copy constructor stores the value directly, so
withArrayElementSeparator(null)leaves_arrayElementSeparator == null.Impact
This breaks the field's non-null invariant:
hasArrayElementSeparator()doesreturn !_arrayElementSeparator.isEmpty();→NullPointerException.withArrayElementSeparator(...)call NPEs on_arrayElementSeparator.equals(sep).Every sibling builder stores exactly the value it compared against (e.g.
withColumnSeparatorcompares_columnSeparator == sepand constructs withsep);withArrayElementSeparatoris the only one that comparessepbut constructs withseparator.Fix
Pass the already-normalized
sep:Tests
Added
CsvSchemaTest.testWithArrayElementSeparatorNull, which sets a separator, clears it withwithArrayElementSeparator(null), and assertshasArrayElementSeparator()returnsfalse(and does not throw) — this fails with an NPE on the current code and passes with the fix.Happy to add a
release-notes/CREDITSentry or sign the CLA if needed.