Search before asking
Describe the bug
JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_VALUES is documented as working for enums ("allows case-insensitive matching of (some) property values, such as Enums"), but it actually has no effect on enum deserialization.
When constructing EnumDeserializer, BaseDeserializerFactory only checks MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS when passing the caseInsensitive parameter.
Also, when searching for occurrences of ACCEPT_CASE_INSENSITIVE_VALUES across all of FasterXML, there are only 17 occurrences. It is straightforward to verify that none of these occurrences affect enum deserialization.
As far as I can tell this has always been true since 2.10 when ACCEPT_CASE_INSENSITIVE_VALUES was introduced, even though it was documented from the start to work with enums.
Version Information
2.21.2, 3.1.0
Reproduction
import com.fasterxml.jackson.annotation.*;
import tools.jackson.databind.ObjectMapper;
enum Status {
SENT,
@JsonEnumDefaultValue UNKNOWN
}
class Response {
@JsonFormat(with = {
JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_VALUES,
JsonFormat.Feature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
})
public Status status;
}
public class Test {
public static void main(String[] args) {
String json = "{\"status\":\"sent\"}";
Response response = new ObjectMapper().readValue(json, Response.class);
System.out.println(response.status); // Expected: SENT, Actual: UNKNOWN
}
}
Search before asking
Describe the bug
JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_VALUES is documented as working for enums ("allows case-insensitive matching of (some) property values, such as Enums"), but it actually has no effect on enum deserialization.
When constructing
EnumDeserializer,BaseDeserializerFactoryonly checksMapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMSwhen passing thecaseInsensitiveparameter.Also, when searching for occurrences of
ACCEPT_CASE_INSENSITIVE_VALUESacross all of FasterXML, there are only 17 occurrences. It is straightforward to verify that none of these occurrences affect enum deserialization.As far as I can tell this has always been true since 2.10 when
ACCEPT_CASE_INSENSITIVE_VALUESwas introduced, even though it was documented from the start to work with enums.Version Information
2.21.2, 3.1.0
Reproduction