@@ -591,10 +591,9 @@ public JsonToken nextToken() throws IOException
591
591
// also: clear any data retained so far
592
592
_binaryValue = null ;
593
593
594
- /* First: need to keep track of lengths of defined-length Arrays and
595
- * Objects (to materialize END_ARRAY/END_OBJECT as necessary);
596
- * as well as handle names for Object entries.
597
- */
594
+ // First: need to keep track of lengths of defined-length Arrays and
595
+ // Objects (to materialize END_ARRAY/END_OBJECT as necessary);
596
+ // as well as handle names for Object entries.
598
597
if (_parsingContext .inObject ()) {
599
598
if (_currToken != JsonToken .FIELD_NAME ) {
600
599
_tagValue = -1 ;
@@ -3422,32 +3421,34 @@ protected void _closeInput() throws IOException {
3422
3421
3423
3422
@ Override
3424
3423
protected void _handleEOF () throws JsonParseException {
3425
- if (!_parsingContext .inRoot ()) {
3426
- String marker = _parsingContext .inArray () ? "Array" : "Object" ;
3427
- _reportInvalidEOF (String .format (
3428
- ": expected close marker for %s (start marker at %s)" ,
3429
- marker ,
3430
- _parsingContext .getStartLocation (_ioContext .getSourceReference ())),
3431
- null );
3424
+ if (_parsingContext .inRoot ()) {
3425
+ return ;
3432
3426
}
3427
+ String marker = _parsingContext .inArray () ? "Array" : "Object" ;
3428
+ _reportInvalidEOF (String .format (
3429
+ ": expected close marker for %s (start marker at %s)" ,
3430
+ marker ,
3431
+ _parsingContext .getStartLocation (_ioContext .getSourceReference ())),
3432
+ null );
3433
3433
}
3434
3434
3435
- /*
3436
- /**********************************************************
3437
- /* Internal methods, error handling, reporting
3438
- /**********************************************************
3439
- */
3440
-
3441
3435
protected JsonToken _handleCBOREOF () throws IOException {
3442
- /* NOTE: here we can and should close input, release buffers,
3443
- * since this is "hard" EOF, not a boundary imposed by
3444
- * header token.
3445
- */
3436
+ // NOTE: here we can and should close input, release buffers, since
3437
+ // this is "hard" EOF, not a boundary imposed by header token.
3446
3438
_tagValue = -1 ;
3447
3439
close ();
3440
+ // 30-Jan-2021, tatu: But also MUST verify that end-of-content is actually
3441
+ // allowed (see [dataformats-binary#240] for example)
3442
+ _handleEOF ();
3448
3443
return (_currToken = null );
3449
3444
}
3450
3445
3446
+ /*
3447
+ /**********************************************************
3448
+ /* Internal methods, error handling, reporting
3449
+ /**********************************************************
3450
+ */
3451
+
3451
3452
protected void _invalidToken (int ch ) throws JsonParseException {
3452
3453
ch &= 0xFF ;
3453
3454
if (ch == 0xFF ) {
0 commit comments