Skip to content

Port JsonPatch START_ARRAY check from jsr-353 module - #92

Merged
cowtowncoder merged 3 commits into
FasterXML:3.xfrom
pjfanning:port-jsonp-patch-array-check
Sep 15, 2026
Merged

cowtowncoder merged 3 commits into
FasterXML:3.xfrom
pjfanning:port-jsonp-patch-array-check

Conversation

@pjfanning

Copy link
Copy Markdown
Member

Problem

Commit 59447f3 ("Fixes wrt [core#1378]") added a START_ARRAY guard — plus two tests — to jsr-353's JsonPatchDeserializer, but the jakarta-jsonp copy of the same class was never updated. The two modules have drifted.

Without the guard, _deserializeArray() calls nextToken() past the end of the document and switches on the resulting null token, so non-Array input fails with a bare NPE:

input read as JsonPatch jsr-353 jakarta-jsonp
"op" InvalidFormatException NullPointerException: Cannot invoke "tools.jackson.core.JsonToken.ordinal()" because "t" is null
42 InvalidFormatException NullPointerException

Fix

Port the guard verbatim from the jsr-353 twin, so both modules report the same InvalidFormatException: JSON patch has to be an array of objects.

Tests

Brings over testObjectDeserializationAndPatching and testScalarDeserializationAndPatching from the jsr-353 test, plus one for numeric input. Adds the standard a2q() helper to TestBase for the new test content.

jakarta-jsonp suite: 26 tests, all green.

pjfanning and others added 2 commits September 9, 2026 10:14
Commit 59447f3 ("Fixes wrt [core#1378]") added a START_ARRAY guard plus two
tests to the jsr-353 `JsonPatchDeserializer`, but the jakarta-jsonp copy was
never updated. Without the guard `_deserializeArray()` reads past the end of
the document and switches on the resulting `null` token, so non-Array input
fails with a bare NPE instead of `InvalidFormatException`:

    input   jsr-353                 jakarta-jsonp
    "op"    InvalidFormatException  NullPointerException: ... "t" is null
    42      InvalidFormatException  NullPointerException

Port the guard verbatim and bring over the two tests (plus one for numbers).
Also add the `a2q()` helper to `TestBase` for the new test content.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@cowtowncoder cowtowncoder added the jsr-353 Issue related to JSR-353/JSONP datatype module label Sep 15, 2026
@cowtowncoder cowtowncoder changed the title (jakarta-jsonp) Port JsonPatch START_ARRAY check from jsr-353 module Port JsonPatch START_ARRAY check from jsr-353 module Sep 15, 2026
@cowtowncoder
cowtowncoder merged commit 7a40b88 into FasterXML:3.x Sep 15, 2026
3 checks passed
cowtowncoder added a commit that referenced this pull request Sep 15, 2026
@cowtowncoder

Copy link
Copy Markdown
Member

Accidentally merged before review, reverted - will try to re-open.

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

Labels

jsr-353 Issue related to JSR-353/JSONP datatype module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants