@@ -605,7 +605,7 @@ public JsonToken nextToken() throws IOException
605
605
_streamReadContext = _streamReadContext .getParent ();
606
606
return (_currToken = JsonToken .END_OBJECT );
607
607
}
608
- return (_currToken = _decodeFieldName ());
608
+ return (_currToken = _decodePropertyName ());
609
609
}
610
610
} else {
611
611
if (!_streamReadContext .expectMoreValues ()) {
@@ -1270,7 +1270,7 @@ public String nextTextValue() throws IOException
1270
1270
_currToken = JsonToken .END_OBJECT ;
1271
1271
return null ;
1272
1272
}
1273
- _currToken = _decodeFieldName ();
1273
+ _currToken = _decodePropertyName ();
1274
1274
return null ;
1275
1275
}
1276
1276
} else {
@@ -2557,7 +2557,7 @@ protected byte[] _finishLongContiguousBytes(final int expLen) throws IOException
2557
2557
}
2558
2558
}
2559
2559
2560
- protected final JsonToken _decodeFieldName () throws IOException
2560
+ protected final JsonToken _decodePropertyName () throws IOException
2561
2561
{
2562
2562
if (_inputPtr >= _inputEnd ) {
2563
2563
loadMoreGuaranteed ();
@@ -3427,12 +3427,35 @@ protected void _handleEOF() throws JsonParseException {
3427
3427
if (_streamReadContext .inRoot ()) {
3428
3428
return ;
3429
3429
}
3430
- String marker = _streamReadContext .inArray () ? "Array" : "Object" ;
3431
- _reportInvalidEOF (String .format (
3432
- ": expected close marker for %s (start marker at %s)" ,
3433
- marker ,
3434
- _streamReadContext .getStartLocation (_ioContext .getSourceReference ())),
3435
- null );
3430
+ // Ok; end-marker or fixed-length Array/Object?
3431
+ final JsonLocation loc = _streamReadContext .getStartLocation (_ioContext .getSourceReference ());
3432
+ final String startLocDesc = (loc == null ) ? "[N/A]" : loc .sourceDescription ();
3433
+ if (_streamReadContext .hasExpectedLength ()) { // specific length
3434
+ final int expMore = _streamReadContext .getRemainingExpectedLength ();
3435
+ if (_streamReadContext .inArray ()) {
3436
+ _reportInvalidEOF (String .format (
3437
+ " in Array value: expected %d more elements (start token at %s)" ,
3438
+ expMore , startLocDesc ),
3439
+ null );
3440
+ } else {
3441
+ _reportInvalidEOF (String .format (
3442
+ " in Object value: expected %d more properties (start token at %s)" ,
3443
+ expMore , startLocDesc ),
3444
+ null );
3445
+ }
3446
+ } else {
3447
+ if (_streamReadContext .inArray ()) {
3448
+ _reportInvalidEOF (String .format (
3449
+ " in Array value: expected an element or close marker (0xFF) (start token at %s)" ,
3450
+ startLocDesc ),
3451
+ null );
3452
+ } else {
3453
+ _reportInvalidEOF (String .format (
3454
+ " in Object value: expected a property or close marker (0xFF) (start token at %s)" ,
3455
+ startLocDesc ),
3456
+ null );
3457
+ }
3458
+ }
3436
3459
}
3437
3460
3438
3461
// Was "_handleCBOREOF()" before 2.13
0 commit comments