-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
So this issue only seems to occur on 2.11, 2.10 works fine and does not throw an exception.
I have the following model with the enum Status
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-08-14T13:53:10.363+01:00")
public class TaskTreeResponseVM {
@JsonProperty("id")
private String id = null;
/**
* Current status of the idea
*/
public enum StatusEnum {
INCOMPLETE("INCOMPLETE"),
COMPLETE("COMPLETE");
private String value;
StatusEnum(String value) {
this.value = value;
}
@Override
@JsonValue
public String toString() {
return String.valueOf(value);
}
@JsonCreator
public static StatusEnum fromValue(String text) {
for (StatusEnum b : StatusEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
return null;
}
}
@JsonProperty("status")
private StatusEnum status = null;
/**
* Current status of the idea
* @return status
**/
@ApiModelProperty(example = "INCOMPLETE", required = true, value = "Current status of the idea")
@NotNull
@Size(max=255)
public StatusEnum getStatus() {
return status;
}
public void setStatus(StatusEnum status) {
this.status = status;
}
Due to an unrelated issue, sometimes an Integer is passed to the Status field, which obviously shouldn't work. However on 2.10, it just ignored it and the field was left as null. Now after upgrading to 2.11 i am having this problem, I see in this linked issue, it seems like that past behaviour was actually a bug #2737
I tried setting READ_UNKNOWN_ENUM_VALUES_AS_NULL=true to allow this to fail gracefully and not throw an exception but it didnt seem to do anything. Am I expecting that config value to do something it doesn't?
Here is my stack trace
Caused by: com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of package.StatusEnum
, problem: argument type mismatch
at [Source: (PushbackInputStream); line: 1, column: 11] (through reference chain: package.TaskTreeResponseVM["status"])
at com.fasterxml.jackson.databind.exc.ValueInstantiationException.from(ValueInstantiationException.java:47)
at com.fasterxml.jackson.databind.DeserializationContext.instantiationException(DeserializationContext.java:1758)
at com.fasterxml.jackson.databind.DeserializationContext.handleInstantiationProblem(DeserializationContext.java:1128)
at com.fasterxml.jackson.databind.deser.std.FactoryBasedEnumDeserializer.deserialize(FactoryBasedEnumDeserializer.java:159)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:371)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:164)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4482)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3487)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:269)
... 10 more