@@ -679,12 +679,12 @@ private JsonToken _handleRootKey(int tag) throws JacksonException
679679 if (_currentField != null ) {
680680 if ((f = _currentField .nextOrThisIf (id )) == null ) {
681681 if ((f = _currentMessage .field (id )) == null ) {
682- return _skipUnknownField (id , wireType );
682+ return _skipUnknownField (id , wireType , false );
683683 }
684684 }
685685 } else {
686686 if ((f = _currentMessage .field (id )) == null ) {
687- return _skipUnknownField (id , wireType );
687+ return _skipUnknownField (id , wireType , false );
688688 }
689689 }
690690 _streamReadContext .setCurrentName (f .name );
@@ -715,12 +715,12 @@ private JsonToken _handleNestedKey(int tag) throws JacksonException
715715 if (_currentField != null ) {
716716 if ((f = _currentField .nextOrThisIf (id )) == null ) {
717717 if ((f = _currentMessage .field (id )) == null ) {
718- return _skipUnknownField (id , wireType );
718+ return _skipUnknownField (id , wireType , true );
719719 }
720720 }
721721 } else {
722722 if ((f = _currentMessage .field (id )) == null ) {
723- return _skipUnknownField (id , wireType );
723+ return _skipUnknownField (id , wireType , true );
724724 }
725725 }
726726
@@ -729,7 +729,7 @@ private JsonToken _handleNestedKey(int tag) throws JacksonException
729729 }
730730 // Note: may be null; if so, value needs to be skipped
731731 if (f == null ) {
732- return _skipUnknownField (id , wireType );
732+ return _skipUnknownField (id , wireType , true );
733733 }
734734 _streamReadContext .setCurrentName (f .name );
735735 if (!f .isValidFor (wireType )) {
@@ -891,8 +891,10 @@ private JsonToken _readNextValue(FieldType t, int nextState) throws JacksonExcep
891891 return type ;
892892 }
893893
894- private JsonToken _skipUnknownField (int tag , int wireType ) throws JacksonException
894+ private JsonToken _skipUnknownField (int tag , int wireType , boolean nestedField ) throws JacksonException
895895 {
896+ //System.out.println(" _skipUnknownField(tag="+tag+", wireType="+wireType+")");
897+
896898 // First: is this even allowed?
897899 if (!isEnabled (StreamReadFeature .IGNORE_UNDEFINED )) {
898900 _reportErrorF ("Undefined property (id %d, wire type %d) for message type %s: not allowed to ignore, as `JsonParser.Feature.IGNORE_UNDEFINED` disabled" ,
@@ -905,7 +907,7 @@ private JsonToken _skipUnknownField(int tag, int wireType) throws JacksonExcepti
905907 if (_checkEnd ()) { // updates _parsingContext
906908 return _updateToken (JsonToken .END_OBJECT );
907909 }
908- if (_state == STATE_NESTED_KEY ) {
910+ if (nestedField ) {
909911 if (_inputPtr >= _inputEnd ) {
910912 loadMoreGuaranteed ();
911913 }
@@ -924,7 +926,14 @@ private JsonToken _skipUnknownField(int tag, int wireType) throws JacksonExcepti
924926 continue ;
925927 }
926928 _streamReadContext .setCurrentName (_currentField .name );
927- _state = STATE_ROOT_VALUE ;
929+
930+ // 30-Apr-2025, tatu: [dataformats-binary#584] may be called for root and nested
931+ if (nestedField ) {
932+ _state = STATE_NESTED_VALUE ;
933+ } else {
934+ _state = STATE_ROOT_VALUE ;
935+ }
936+
928937 // otherwise quickly validate compatibility
929938 if (!_currentField .isValidFor (wireType )) {
930939 _reportIncompatibleType (_currentField , wireType );
@@ -980,7 +989,7 @@ public String nextName() throws JacksonException
980989
981990 ProtobufField f = _findField (id );
982991 if (f == null ) {
983- if (_skipUnknownField (id , wireType ) != JsonToken .PROPERTY_NAME ) {
992+ if (_skipUnknownField (id , wireType , false ) != JsonToken .PROPERTY_NAME ) {
984993 return null ;
985994 }
986995 // sub-optimal as skip method already set it, but:
@@ -1017,7 +1026,7 @@ public String nextName() throws JacksonException
10171026
10181027 ProtobufField f = _findField (id );
10191028 if (f == null ) {
1020- if (_skipUnknownField (id , wireType ) != JsonToken .PROPERTY_NAME ) {
1029+ if (_skipUnknownField (id , wireType , true ) != JsonToken .PROPERTY_NAME ) {
10211030 return null ;
10221031 }
10231032 // sub-optimal as skip method already set it, but:
@@ -1068,7 +1077,7 @@ public boolean nextName(SerializableString sstr) throws JacksonException
10681077
10691078 ProtobufField f = _findField (id );
10701079 if (f == null ) {
1071- _skipUnknownField (id , wireType );
1080+ _skipUnknownField (id , wireType , false );
10721081 // may or may not match, but let caller figure it out
10731082 return false ;
10741083 }
@@ -1104,7 +1113,7 @@ public boolean nextName(SerializableString sstr) throws JacksonException
11041113
11051114 ProtobufField f = _findField (id );
11061115 if (f == null ) {
1107- _skipUnknownField (id , wireType );
1116+ _skipUnknownField (id , wireType , true );
11081117 // may or may not match, but let caller figure it out
11091118 return false ;
11101119 }
@@ -1154,7 +1163,7 @@ public int nextNameMatch(PropertyNameMatcher matcher) throws JacksonException
11541163
11551164 ProtobufField f = _findField (id );
11561165 if (f == null ) {
1157- JsonToken t = _skipUnknownField (id , wireType );
1166+ JsonToken t = _skipUnknownField (id , wireType , false );
11581167 if (t != JsonToken .PROPERTY_NAME ) {
11591168 return (t == JsonToken .END_OBJECT )
11601169 ? PropertyNameMatcher .MATCH_END_OBJECT : PropertyNameMatcher .MATCH_ODD_TOKEN ;
@@ -1192,7 +1201,7 @@ public int nextNameMatch(PropertyNameMatcher matcher) throws JacksonException
11921201
11931202 ProtobufField f = _findField (id );
11941203 if (f == null ) {
1195- JsonToken t = _skipUnknownField (id , wireType );
1204+ JsonToken t = _skipUnknownField (id , wireType , true );
11961205 if (t != JsonToken .PROPERTY_NAME ) {
11971206 return (t == JsonToken .END_OBJECT )
11981207 ? PropertyNameMatcher .MATCH_END_OBJECT : PropertyNameMatcher .MATCH_ODD_TOKEN ;
0 commit comments