Skip to content

(jakarta-jsonp) Port JsonPatch START_ARRAY check from jsr-353 module - #92

Open
pjfanning wants to merge 2 commits into
FasterXML:3.xfrom
pjfanning:port-jsonp-patch-array-check
Open

(jakarta-jsonp) Port JsonPatch START_ARRAY check from jsr-353 module#92
pjfanning wants to merge 2 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>
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.

1 participant