Skip to content

Wrong/misleading error for "extra" close token (] or }) when at root level #1394

@cowtowncoder

Description

@cowtowncoder

(note: found as part of work on FasterXML/jackson-databind#4902 to enable "fail on extra tokens" DeserializationFeature).

So: odd failures seen for tests:

[ERROR]   TestSubtypesExternalPropertyMissingProperty.testDeserializationNull:141->checkOrangeBoxNull:232 » 
  JsonParse Unexpected close marker '}': expected ']' (for root starting
   at [Source: (String)"{"type":"orange","fruit":null}}"; line: 1, column: 0])

which is due to ReaderBasedJsonParser (and others), on:

    private void _closeScope(int i) throws IOException {
        if (i == INT_RBRACKET) {
            _updateLocation();
            if (!_parsingContext.inArray()) {
                _reportMismatchedEndMarker(i, '}');
            }
            _parsingContext = _parsingContext.clearAndGetParent();
            _updateToken(JsonToken.END_ARRAY);
        }
        ...
   }

in which check is assuming there always IS a start marker -- but fails to consider case where there is no open scope. It should.

This needs to be checked against all 4 backends

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions