@@ -679,12 +679,12 @@ private JsonToken _handleRootKey(int tag) throws JacksonException
679
679
if (_currentField != null ) {
680
680
if ((f = _currentField .nextOrThisIf (id )) == null ) {
681
681
if ((f = _currentMessage .field (id )) == null ) {
682
- return _skipUnknownField (id , wireType );
682
+ return _skipUnknownField (id , wireType , false );
683
683
}
684
684
}
685
685
} else {
686
686
if ((f = _currentMessage .field (id )) == null ) {
687
- return _skipUnknownField (id , wireType );
687
+ return _skipUnknownField (id , wireType , false );
688
688
}
689
689
}
690
690
_streamReadContext .setCurrentName (f .name );
@@ -715,12 +715,12 @@ private JsonToken _handleNestedKey(int tag) throws JacksonException
715
715
if (_currentField != null ) {
716
716
if ((f = _currentField .nextOrThisIf (id )) == null ) {
717
717
if ((f = _currentMessage .field (id )) == null ) {
718
- return _skipUnknownField (id , wireType );
718
+ return _skipUnknownField (id , wireType , true );
719
719
}
720
720
}
721
721
} else {
722
722
if ((f = _currentMessage .field (id )) == null ) {
723
- return _skipUnknownField (id , wireType );
723
+ return _skipUnknownField (id , wireType , true );
724
724
}
725
725
}
726
726
@@ -729,7 +729,7 @@ private JsonToken _handleNestedKey(int tag) throws JacksonException
729
729
}
730
730
// Note: may be null; if so, value needs to be skipped
731
731
if (f == null ) {
732
- return _skipUnknownField (id , wireType );
732
+ return _skipUnknownField (id , wireType , true );
733
733
}
734
734
_streamReadContext .setCurrentName (f .name );
735
735
if (!f .isValidFor (wireType )) {
@@ -891,8 +891,10 @@ private JsonToken _readNextValue(FieldType t, int nextState) throws JacksonExcep
891
891
return type ;
892
892
}
893
893
894
- private JsonToken _skipUnknownField (int tag , int wireType ) throws JacksonException
894
+ private JsonToken _skipUnknownField (int tag , int wireType , boolean nestedField ) throws JacksonException
895
895
{
896
+ //System.out.println(" _skipUnknownField(tag="+tag+", wireType="+wireType+")");
897
+
896
898
// First: is this even allowed?
897
899
if (!isEnabled (StreamReadFeature .IGNORE_UNDEFINED )) {
898
900
_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
905
907
if (_checkEnd ()) { // updates _parsingContext
906
908
return _updateToken (JsonToken .END_OBJECT );
907
909
}
908
- if (_state == STATE_NESTED_KEY ) {
910
+ if (nestedField ) {
909
911
if (_inputPtr >= _inputEnd ) {
910
912
loadMoreGuaranteed ();
911
913
}
@@ -924,7 +926,14 @@ private JsonToken _skipUnknownField(int tag, int wireType) throws JacksonExcepti
924
926
continue ;
925
927
}
926
928
_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
+
928
937
// otherwise quickly validate compatibility
929
938
if (!_currentField .isValidFor (wireType )) {
930
939
_reportIncompatibleType (_currentField , wireType );
@@ -980,7 +989,7 @@ public String nextName() throws JacksonException
980
989
981
990
ProtobufField f = _findField (id );
982
991
if (f == null ) {
983
- if (_skipUnknownField (id , wireType ) != JsonToken .PROPERTY_NAME ) {
992
+ if (_skipUnknownField (id , wireType , false ) != JsonToken .PROPERTY_NAME ) {
984
993
return null ;
985
994
}
986
995
// sub-optimal as skip method already set it, but:
@@ -1017,7 +1026,7 @@ public String nextName() throws JacksonException
1017
1026
1018
1027
ProtobufField f = _findField (id );
1019
1028
if (f == null ) {
1020
- if (_skipUnknownField (id , wireType ) != JsonToken .PROPERTY_NAME ) {
1029
+ if (_skipUnknownField (id , wireType , true ) != JsonToken .PROPERTY_NAME ) {
1021
1030
return null ;
1022
1031
}
1023
1032
// sub-optimal as skip method already set it, but:
@@ -1068,7 +1077,7 @@ public boolean nextName(SerializableString sstr) throws JacksonException
1068
1077
1069
1078
ProtobufField f = _findField (id );
1070
1079
if (f == null ) {
1071
- _skipUnknownField (id , wireType );
1080
+ _skipUnknownField (id , wireType , false );
1072
1081
// may or may not match, but let caller figure it out
1073
1082
return false ;
1074
1083
}
@@ -1104,7 +1113,7 @@ public boolean nextName(SerializableString sstr) throws JacksonException
1104
1113
1105
1114
ProtobufField f = _findField (id );
1106
1115
if (f == null ) {
1107
- _skipUnknownField (id , wireType );
1116
+ _skipUnknownField (id , wireType , true );
1108
1117
// may or may not match, but let caller figure it out
1109
1118
return false ;
1110
1119
}
@@ -1154,7 +1163,7 @@ public int nextNameMatch(PropertyNameMatcher matcher) throws JacksonException
1154
1163
1155
1164
ProtobufField f = _findField (id );
1156
1165
if (f == null ) {
1157
- JsonToken t = _skipUnknownField (id , wireType );
1166
+ JsonToken t = _skipUnknownField (id , wireType , false );
1158
1167
if (t != JsonToken .PROPERTY_NAME ) {
1159
1168
return (t == JsonToken .END_OBJECT )
1160
1169
? PropertyNameMatcher .MATCH_END_OBJECT : PropertyNameMatcher .MATCH_ODD_TOKEN ;
@@ -1192,7 +1201,7 @@ public int nextNameMatch(PropertyNameMatcher matcher) throws JacksonException
1192
1201
1193
1202
ProtobufField f = _findField (id );
1194
1203
if (f == null ) {
1195
- JsonToken t = _skipUnknownField (id , wireType );
1204
+ JsonToken t = _skipUnknownField (id , wireType , true );
1196
1205
if (t != JsonToken .PROPERTY_NAME ) {
1197
1206
return (t == JsonToken .END_OBJECT )
1198
1207
? PropertyNameMatcher .MATCH_END_OBJECT : PropertyNameMatcher .MATCH_ODD_TOKEN ;
0 commit comments