@@ -360,18 +360,18 @@ final static class EnumKD extends JDKKeyDeserializer
360
360
protected final AnnotatedMethod _factory ;
361
361
362
362
/**
363
- * Lazily constructed alternative in case there is need to
364
- * use 'toString()' method as the source .
363
+ * Alternative resolver to parse enums with {@code toString()} method as the source.
364
+ * Works when {@link DeserializationFeature#READ_ENUMS_USING_TO_STRING} is enabled .
365
365
*/
366
366
protected final EnumResolver _byToStringResolver ;
367
367
368
368
/**
369
- * Lazily constructed alternative in case there is need to
370
- * parse using enum index method as the source .
369
+ * Alternative resolver to parse enums with {@link Enum#ordinal()} method as the source.
370
+ * Works when {@link EnumFeature#READ_ENUM_KEYS_USING_INDEX} is enabled .
371
371
*
372
372
* @since 2.15
373
373
*/
374
- protected volatile EnumResolver _byIndexResolver ;
374
+ protected final EnumResolver _byIndexResolver ;
375
375
376
376
/**
377
377
* Look up map with <b>key</b> as <code>Enum.name()</code> converted by
@@ -416,8 +416,9 @@ public Object _parse(String key, DeserializationContext ctxt)
416
416
Enum <?> e = res .findEnum (key );
417
417
// If enum is found, no need to try deser using index
418
418
if (e == null && ctxt .isEnabled (EnumFeature .READ_ENUM_KEYS_USING_INDEX )) {
419
- res = _getIndexResolver (ctxt );
420
- e = res .findEnum (key );
419
+ if (_byIndexResolver != null ) {
420
+ e = _byIndexResolver .findEnum (key );
421
+ }
421
422
}
422
423
if (e == null ) {
423
424
if ((_enumDefaultValue != null )
@@ -443,29 +444,6 @@ protected EnumResolver _resolveCurrentResolver(DeserializationContext ctxt) {
443
444
? _byToStringResolver
444
445
: _byNameResolver ;
445
446
}
446
-
447
- /**
448
- * Since 2.16, {@link #_byIndexResolver} it is passed via
449
- * {@link #EnumKD(EnumResolver, AnnotatedMethod, EnumResolver, EnumResolver, EnumResolver)}, so there is no need for lazy
450
- * initialization. But kept for backward-compatibility reasons.
451
- *
452
- * @deprecated Since 2.16
453
- */
454
- @ Deprecated
455
- private EnumResolver _getIndexResolver (DeserializationContext ctxt ) {
456
- EnumResolver res = _byIndexResolver ;
457
- if (res == null ) {
458
- synchronized (this ) {
459
- res = _byIndexResolver ;
460
- if (res == null ) {
461
- res = EnumResolver .constructUsingIndex (ctxt .getConfig (),
462
- _byNameResolver .getEnumClass ());
463
- _byIndexResolver = res ;
464
- }
465
- }
466
- }
467
- return res ;
468
- }
469
447
}
470
448
471
449
/**
0 commit comments