File tree Expand file tree Collapse file tree 3 files changed +24
-7
lines changed
main/java/com/fasterxml/jackson/dataformat/cbor
test/java/com/fasterxml/jackson/dataformat/cbor Expand file tree Collapse file tree 3 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -3414,6 +3414,25 @@ protected void _skipIncomplete() throws IOException
34143414 && type != CBORConstants .MAJOR_TYPE_BYTES ) {
34153415 _throwInternal ();
34163416 }
3417+
3418+ // [dataformats-binary#599]: If we are in a stringref namespace, we need to
3419+ // actually read and store the string/bytes value instead of just skipping it,
3420+ // so that later string references can find it.
3421+ // The finish methods will determine if the value should be added to the
3422+ // reference table based on shouldReferenceString().
3423+ if (!_stringRefs .empty ()) {
3424+ if (type == CBORConstants .MAJOR_TYPE_TEXT ) {
3425+ // Need to actually read the text (which may add to stringRefs)
3426+ _finishTextToken (_typeByte );
3427+ } else {
3428+ // For bytes: decode length then read (which may add to stringRefs)
3429+ int len = _decodeExplicitLength (_typeByte & 0x1F );
3430+ _finishBytes (len );
3431+ }
3432+ return ;
3433+ }
3434+
3435+ // Standard skip logic when not in stringref namespace
34173436 final int lowBits = _typeByte & 0x1F ;
34183437 if (lowBits <= 23 ) {
34193438 if (lowBits > 0 ) {
Original file line number Diff line number Diff line change 1- package com .fasterxml .jackson .dataformat .cbor . tofix ;
1+ package com .fasterxml .jackson .dataformat .cbor ;
22
33import java .util .Arrays ;
44
5+ import org .junit .jupiter .api .Test ;
6+
57import com .fasterxml .jackson .core .JsonToken ;
68import com .fasterxml .jackson .databind .ObjectMapper ;
79
8- import com .fasterxml .jackson .dataformat .cbor .*;
9- import com .fasterxml .jackson .dataformat .cbor .testutil .failure .JacksonTestFailureExpected ;
10-
1110import static org .junit .jupiter .api .Assertions .assertEquals ;
1211
13- import org .junit .jupiter .api .Test ;
14-
1512public class StringRef599Test extends CBORTestBase
1613{
1714 private final ObjectMapper VANILLA_MAPPER = cborMapper ();
@@ -27,7 +24,6 @@ public void testDupsNoStringRef() throws Exception
2724 }
2825
2926 // [dataformats-binary#599]
30- @ JacksonTestFailureExpected
3127 @ Test
3228 public void testDupsWithStringRef () throws Exception
3329 {
Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ No changes since 2.19.1
9090
91912.18 .5 (not yet released )
9292
93+ #599 : (cbor) Unable to deserialize stringref-enabled CBOR with ignored properties
94+ (reported by Yohei K )
9395#623 : (ion) Upgrade `ion-java` dep to 1.11.11 (from 1.11.10)
9496 (requested by @Shaurya0108 )
9597
You can’t perform that action at this time.
0 commit comments