Skip to content

Commit

Permalink
Fixed to give priority to KeyDeserializer set by annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Jan 26, 2025
1 parent d2a7c4a commit a7538fb
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1269,8 +1269,11 @@ public KeyDeserializer createKeyDeserializer(DeserializationContext ctxt,
{
final DeserializationConfig config = ctxt.getConfig();
final BeanDescription beanDesc = config.introspectClassAnnotations(type);
KeyDeserializer deser = null;
if (_factoryConfig.hasKeyDeserializers()) {

// [databind#2452]: Support `@JsonDeserialize(keyUsing = ...)`
KeyDeserializer deser = findKeyDeserializerFromAnnotation(ctxt, beanDesc.getClassInfo());

if (deser == null && _factoryConfig.hasKeyDeserializers()) {
for (KeyDeserializers d : _factoryConfig.keyDeserializers()) {
deser = d.findKeyDeserializer(type, config, beanDesc);
if (deser != null) {
Expand All @@ -1281,14 +1284,10 @@ public KeyDeserializer createKeyDeserializer(DeserializationContext ctxt,

// the only non-standard thing is this:
if (deser == null) {
// [databind#2452]: Support `@JsonDeserialize(keyUsing = ...)`
deser = findKeyDeserializerFromAnnotation(ctxt, beanDesc.getClassInfo());
if (deser == null) {
if (type.isEnumType()) {
deser = _createEnumKeyDeserializer(ctxt, type);
} else {
deser = StdKeyDeserializers.findStringBasedKeyDeserializer(config, type);
}
if (type.isEnumType()) {
deser = _createEnumKeyDeserializer(ctxt, type);
} else {
deser = StdKeyDeserializers.findStringBasedKeyDeserializer(config, type);
}
}
// and then post-processing
Expand Down

0 comments on commit a7538fb

Please sign in to comment.