FasterXML / FasterXML/jackson-modules-java8
Cannot read Optionals written with StdTypeResolverBuilder
- Dominant language
- Java
- Stars
- 425
- Forks
- 124
- PR merge metrics
- No merged PRs in 30d
Description
The following test fails on Jackson 2.9.7 and passes on 2.8.11:
```
@Test
public void test() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.setDefaultTyping(
new StdTypeResolverBuilder()
.init(JsonTypeInfo.Id.CLASS, null)
.inclusion(JsonTypeInfo.As.WRAPPER_OBJECT)
);
mapper.registerModule(new Jdk8Module());
String json = mapper.writeValueAsString(new Foo(Optional.of(1)));
System.out.println(json);
mapper.readValue(json, Foo.class);
}
public static class Foo {
private Optional bar;
public Foo() {
}
public Foo(Optional bar) {
this.bar = bar;
}
public Optional getBar() {
return bar;
}
public void setBar(Optional bar) {
this.bar = bar;
}
}
```
Complete runnable project with this test-case can be found on https://github.com/isopov/jackson-optional-test
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.