cyclops-integration
cyclops-integration copied to clipboard
Jackson integration module incompatible with Jackson > 2.10.5
The jackson integration module is incompatible with Jackson versions > 2.10.5.
A backwards compatible fix would be:
From:
---
@Override
public JsonDeserializer<?> findReferenceDeserializer(ReferenceType type,
DeserializationConfig config, BeanDescription bean,
TypeDeserializer typeDeserializer, JsonDeserializer<?> jsonDeserializer) throws JsonMappingException {
return super.findReferenceDeserializer(type, config, bean, typeDeserializer, jsonDeserializer);
}
---
To:
---
@Override
public JsonDeserializer<?> findReferenceDeserializer(ReferenceType type,
DeserializationConfig config, BeanDescription bean,
TypeDeserializer typeDeserializer, JsonDeserializer<?> jsonDeserializer) throws JsonMappingException {
return this.findBeanDeserializer(type, config, bean);
}
Accepting PRs?
Test case. Works with 2.10.5, does not work with 2.11.x
public class DeserializerTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
static {
OBJECT_MAPPER.registerModule(new CyclopsModule());
}
@Test
@SneakyThrows
public void testDeserialize() {
TestDTO testDTO = OBJECT_MAPPER.readValue("{\"seqOfStrings\": [\"hello\"], \"maybeString\": \"world\"}", TestDTO.class);
assertThat(testDTO.seqOfStrings).isNotNull();
assertThat(testDTO.maybeString).isNotNull();
}
@Getter
@ToString
@RequiredArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public static class TestDTO {
@Valid
@NonNull
public final Seq<String> seqOfStrings;
@Valid
@NonNull
public final Option<String> maybeString;
}
}