Unable to deserialize stringref-enabled CBOR with ignored properties (original) (raw)

When deserializing CBOR with string references enabled using jackson-dataformats-binary, if the original string being referenced is in a field ignored by an annotation such as @JsonIgnoreProperties, the string reference cannot be resolved, causing an exception.

version: 2.17.1

record APub(String a, String b) {} @JsonIgnoreProperties(ignoreUnknown = true) record ASub(String b) {}

@Test public void testCborDecode() throws IOException { var mapper = CBORMapper.builder.enable(CBORGenerator.Feature.STRINGREF).build(); var aPub = new APub("foo", "foo"); // second occurrence of foo will be a stringref var aSer = mapper.writeValueAsBytes(aPub); var aSub = mapper.readValue(aSer, ASub.class); // <- throws com.fasterxml.jackson.core.JsonParseException: String reference (0) out of range: }