@@ -715,17 +715,14 @@ public ValueDeserializer<?> createArrayDeserializer(DeserializationContext ctxt,
715715 ArrayType type , BeanDescription .Supplier beanDescRef )
716716 {
717717 final DeserializationConfig config = ctxt .getConfig ();
718- JavaType elemType = type .getContentType ();
718+ final JavaType elemType = type .getContentType ();
719719
720720 // Very first thing: is deserializer hard-coded for elements?
721721 @ SuppressWarnings ("unchecked" )
722- ValueDeserializer <Object > contentDeser = (ValueDeserializer <Object >) elemType .getValueHandler ();
722+ final ValueDeserializer <Object > contentDeser = (ValueDeserializer <Object >) elemType .getValueHandler ();
723723 // Then optional type info: if type has been resolved, we may already know type deserializer:
724- TypeDeserializer elemTypeDeser = (TypeDeserializer ) elemType .getTypeHandler ();
725- // but if not, may still be possible to find:
726- if (elemTypeDeser == null ) {
727- elemTypeDeser = ctxt .findTypeDeserializer (elemType );
728- }
724+ final TypeDeserializer elemTypeDeser = _findContentTypeDeserializer (ctxt , elemType );
725+
729726 // 23-Nov-2010, tatu: Custom array deserializer?
730727 ValueDeserializer <?> deser = _findCustomArrayDeserializer (type ,
731728 config , beanDescRef , elemTypeDeser , contentDeser );
@@ -761,21 +758,11 @@ public ValueDeserializer<?> createArrayDeserializer(DeserializationContext ctxt,
761758 public ValueDeserializer <?> createCollectionDeserializer (DeserializationContext ctxt ,
762759 CollectionType type , BeanDescription .Supplier beanDescRef )
763760 {
764- JavaType contentType = type .getContentType ();
765- // Very first thing: is deserializer hard-coded for elements?
766- ValueDeserializer < Object > contentDeser = ( ValueDeserializer < Object >) contentType . getValueHandler ( );
761+ final JavaType contentType = type .getContentType ();
762+ final ValueDeserializer < Object > contentDeser = ( ValueDeserializer < Object >) contentType . getValueHandler ();
763+ final TypeDeserializer contentTypeDeser = _findContentTypeDeserializer ( ctxt , contentType );
767764 final DeserializationConfig config = ctxt .getConfig ();
768765
769- // Then optional type info: if type has been resolved, we may already know type deserializer:
770- TypeDeserializer contentTypeDeser = (TypeDeserializer ) contentType .getTypeHandler ();
771- // [databind#1654]: @JsonTypeInfo(use = Id.NONE) should not apply type deserializer
772- // when custom content deserializer is specified via @JsonDeserialize(contentUsing = ...)
773- if (contentTypeDeser instanceof NoOpTypeDeserializer ) {
774- contentTypeDeser = null ;
775- } else if (contentTypeDeser == null ) {
776- // but if not, may still be possible to find:
777- contentTypeDeser = ctxt .findTypeDeserializer (contentType );
778- }
779766 // 23-Nov-2010, tatu: Custom deserializer?
780767 ValueDeserializer <?> deser = _findCustomCollectionDeserializer (type ,
781768 config , beanDescRef , contentTypeDeser , contentDeser );
@@ -858,18 +845,13 @@ protected CollectionType _mapAbstractCollectionType(JavaType type, Deserializati
858845 public ValueDeserializer <?> createCollectionLikeDeserializer (DeserializationContext ctxt ,
859846 CollectionLikeType type , BeanDescription .Supplier beanDescRef )
860847 {
861- JavaType contentType = type .getContentType ();
848+ final JavaType contentType = type .getContentType ();
862849 // Very first thing: is deserializer hard-coded for elements?
863850 @ SuppressWarnings ("unchecked" )
864851 ValueDeserializer <Object > contentDeser = (ValueDeserializer <Object >) contentType .getValueHandler ();
865852 final DeserializationConfig config = ctxt .getConfig ();
853+ final TypeDeserializer contentTypeDeser = _findContentTypeDeserializer (ctxt , contentType );
866854
867- // Then optional type info: if type has been resolved, we may already know type deserializer:
868- TypeDeserializer contentTypeDeser = (TypeDeserializer )contentType .getTypeHandler ();
869- // but if not, may still be possible to find:
870- if (contentTypeDeser == null ) {
871- contentTypeDeser = ctxt .findTypeDeserializer (contentType );
872- }
873855 ValueDeserializer <?> deser = _findCustomCollectionLikeDeserializer (type , config , beanDescRef ,
874856 contentTypeDeser , contentDeser );
875857 if (deser != null ) {
@@ -894,8 +876,8 @@ public ValueDeserializer<?> createMapDeserializer(DeserializationContext ctxt,
894876 MapType type , BeanDescription .Supplier beanDescRef )
895877 {
896878 final DeserializationConfig config = ctxt .getConfig ();
897- JavaType keyType = type .getKeyType ();
898- JavaType contentType = type .getContentType ();
879+ final JavaType keyType = type .getKeyType ();
880+ final JavaType contentType = type .getContentType ();
899881
900882 // First: is there annotation-specified deserializer for values?
901883 @ SuppressWarnings ("unchecked" )
@@ -904,11 +886,7 @@ public ValueDeserializer<?> createMapDeserializer(DeserializationContext ctxt,
904886 // Ok: need a key deserializer (null indicates 'default' here)
905887 KeyDeserializer keyDes = (KeyDeserializer ) keyType .getValueHandler ();
906888 // Then optional type info; either attached to type, or resolved separately:
907- TypeDeserializer contentTypeDeser = (TypeDeserializer ) contentType .getTypeHandler ();
908- // but if not, may still be possible to find:
909- if (contentTypeDeser == null ) {
910- contentTypeDeser = ctxt .findTypeDeserializer (contentType );
911- }
889+ final TypeDeserializer contentTypeDeser = _findContentTypeDeserializer (ctxt , contentType );
912890
913891 // 23-Nov-2010, tatu: Custom deserializer?
914892 ValueDeserializer <?> deser = _findCustomMapDeserializer (type , config , beanDescRef ,
@@ -1012,8 +990,8 @@ protected MapType _mapAbstractMapType(JavaType type, DeserializationConfig confi
1012990 public ValueDeserializer <?> createMapLikeDeserializer (DeserializationContext ctxt ,
1013991 MapLikeType type , BeanDescription .Supplier beanDescRef )
1014992 {
1015- JavaType keyType = type .getKeyType ();
1016- JavaType contentType = type .getContentType ();
993+ final JavaType keyType = type .getKeyType ();
994+ final JavaType contentType = type .getContentType ();
1017995 final DeserializationConfig config = ctxt .getConfig ();
1018996
1019997 // First: is there annotation-specified deserializer for values?
@@ -1028,11 +1006,7 @@ public ValueDeserializer<?> createMapLikeDeserializer(DeserializationContext ctx
10281006 }
10291007 */
10301008 // Then optional type info; either attached to type, or resolve separately:
1031- TypeDeserializer contentTypeDeser = (TypeDeserializer ) contentType .getTypeHandler ();
1032- // but if not, may still be possible to find:
1033- if (contentTypeDeser == null ) {
1034- contentTypeDeser = ctxt .findTypeDeserializer (contentType );
1035- }
1009+ final TypeDeserializer contentTypeDeser = _findContentTypeDeserializer (ctxt , contentType );
10361010 ValueDeserializer <?> deser = _findCustomMapLikeDeserializer (type , config ,
10371011 beanDescRef , keyDes , contentTypeDeser , contentDeser );
10381012 if (deser != null ) {
@@ -1743,6 +1717,24 @@ protected boolean _hasCreatorAnnotation(MapperConfig<?> config,
17431717 return false ;
17441718 }
17451719
1720+ // @since 3.1
1721+ protected TypeDeserializer _findContentTypeDeserializer (DeserializationContext ctxt ,
1722+ JavaType contentType )
1723+ {
1724+ // Then optional type info: if type has been resolved, we may already know type deserializer:
1725+ TypeDeserializer contentTypeDeser = (TypeDeserializer ) contentType .getTypeHandler ();
1726+ // [databind#1654]: @JsonTypeInfo(use = Id.NONE) should not apply type deserializer
1727+ // when custom content deserializer is specified via @JsonDeserialize(contentUsing = ...)
1728+ if (contentTypeDeser instanceof NoOpTypeDeserializer ) {
1729+ return null ;
1730+ }
1731+ if (contentTypeDeser == null ) {
1732+ // but if not, may still be possible to find:
1733+ contentTypeDeser = ctxt .findTypeDeserializer (contentType );
1734+ }
1735+ return contentTypeDeser ;
1736+ }
1737+
17461738 /*
17471739 /**********************************************************************
17481740 /* Helper classes
0 commit comments