Skip to content

Unable to deserialize stringref-enabled CBOR with ignored properties #599

Open
@morokosi

Description

@morokosi

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:
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.18cborhas-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions