-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
has-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issueIndicates that there exists a test case (under `failing/`) to reproduce the issueproperty-discoveryProblem with property discovery (introspection)Problem with property discovery (introspection)
Milestone
Description
Everything works as expected if you remove
.withVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
or
mapper.setDefaultSetterInfo(JsonSetter.Value.construct(Nulls.AS_EMPTY, Nulls.AS_EMPTY));
Otherwise error thrown:
Cannot create empty instance of [simple type, class dk.xakeps.jacksontest.Test$Internal], no default Creator
jackson-databind 2.9.9.3
Test class:
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
public class Test {
public static void main(String[] args) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setDefaultSetterInfo(JsonSetter.Value.construct(Nulls.AS_EMPTY, Nulls.AS_EMPTY));
mapper.setVisibility(mapper.getVisibilityChecker().withVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY));
TestCase o = mapper.reader(new InjectableValues.Std().addValue(Internal.class, new Internal("test")))
.forType(TestCase.class)
.readValue("{\"id\":3}");
System.out.println(o.str);
}
public static final class TestCase {
private final Internal str;
private final int id;
@JsonCreator
public TestCase(@JacksonInject Internal str, @JsonProperty("id") int id) {
this.str = str;
this.id = id;
}
}
public static final class Internal {
private final String val;
public Internal(String val) {
this.val = val;
}
}
}Metadata
Metadata
Assignees
Labels
has-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issueIndicates that there exists a test case (under `failing/`) to reproduce the issueproperty-discoveryProblem with property discovery (introspection)Problem with property discovery (introspection)