Skip to content

Commit a7538fb

Browse files
committed
Fixed to give priority to KeyDeserializer set by annotation
Fixes FasterXML#4444
1 parent d2a7c4a commit a7538fb

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,8 +1269,11 @@ public KeyDeserializer createKeyDeserializer(DeserializationContext ctxt,
12691269
{
12701270
final DeserializationConfig config = ctxt.getConfig();
12711271
final BeanDescription beanDesc = config.introspectClassAnnotations(type);
1272-
KeyDeserializer deser = null;
1273-
if (_factoryConfig.hasKeyDeserializers()) {
1272+
1273+
// [databind#2452]: Support `@JsonDeserialize(keyUsing = ...)`
1274+
KeyDeserializer deser = findKeyDeserializerFromAnnotation(ctxt, beanDesc.getClassInfo());
1275+
1276+
if (deser == null && _factoryConfig.hasKeyDeserializers()) {
12741277
for (KeyDeserializers d : _factoryConfig.keyDeserializers()) {
12751278
deser = d.findKeyDeserializer(type, config, beanDesc);
12761279
if (deser != null) {
@@ -1281,14 +1284,10 @@ public KeyDeserializer createKeyDeserializer(DeserializationContext ctxt,
12811284

12821285
// the only non-standard thing is this:
12831286
if (deser == null) {
1284-
// [databind#2452]: Support `@JsonDeserialize(keyUsing = ...)`
1285-
deser = findKeyDeserializerFromAnnotation(ctxt, beanDesc.getClassInfo());
1286-
if (deser == null) {
1287-
if (type.isEnumType()) {
1288-
deser = _createEnumKeyDeserializer(ctxt, type);
1289-
} else {
1290-
deser = StdKeyDeserializers.findStringBasedKeyDeserializer(config, type);
1291-
}
1287+
if (type.isEnumType()) {
1288+
deser = _createEnumKeyDeserializer(ctxt, type);
1289+
} else {
1290+
deser = StdKeyDeserializers.findStringBasedKeyDeserializer(config, type);
12921291
}
12931292
}
12941293
// and then post-processing

0 commit comments

Comments
 (0)