You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unable to override DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE with JsonFormat.Feature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE#4489
Closed
1 task done
JooHyukKim opened this issue
Apr 20, 2024
· 0 comments
I searched in the issues and found nothing similar.
Describe the bug
After #4481, I checked if we have anything else in EnumDeserializer that won't override. READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE config does not work also.
Version Information
2.17.0
Reproduction
(Copied from my PR)
enumTypes {
@JsonEnumDefaultValueDEFAULT_TYPE,
FAST, SLOW
}
staticclassSpeedWithoutDefaultOverride {
@JsonFormat(without = JsonFormat.Feature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE)
publicTypestype;
}
staticclassSpeedWithDefaultOverride {
@JsonFormat(with = JsonFormat.Feature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE)
publicTypestype;
}
@TestpublicvoidtestJsonEnumDefaultValueOverrideOverGlobalConfig() throwsException {
finalStringUNKNOWN_JSON = a2q("{'type':'OOPS!'}");
// First, global configuration is ENABLED and JsonFeature configuration is DISABLED// So the test should failtry {
JsonMapper.builder()
.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE)
.build()
.readValue(UNKNOWN_JSON, SpeedWithoutDefaultOverride.class);
fail();
} catch (InvalidFormatExceptione) {
verifyException(e, "Cannot deserialize value of type");
verifyException(e, "not one of the values accepted for Enum class");
}
// Second, global configuration is DISABLED and JsonFeature configuration is ENABLED// So the test should passSpeedWithDefaultOverridepojo = JsonMapper.builder()
.disable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE)
.build()
.readValue(UNKNOWN_JSON, SpeedWithDefaultOverride.class);
assertEquals(Types.DEFAULT_TYPE, pojo.type);
}
Expected behavior
Be able to override DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE with JsonFormat.Feature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
Additional context
Filed a PR to fix this issue.
The text was updated successfully, but these errors were encountered:
Search before asking
Describe the bug
After #4481, I checked if we have anything else in
EnumDeserializer
that won't override.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
config does not work also.Version Information
2.17.0
Reproduction
(Copied from my PR)
Expected behavior
Be able to override
DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
withJsonFormat.Feature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
Additional context
Filed a PR to fix this issue.
The text was updated successfully, but these errors were encountered: