2424import tools .jackson .databind .ext .jdk8 .OptionalLongDeserializer ;
2525import tools .jackson .databind .introspect .*;
2626import tools .jackson .databind .jsontype .TypeDeserializer ;
27+ import tools .jackson .databind .jsontype .impl .NoOpTypeDeserializer ;
2728import tools .jackson .databind .type .*;
2829import tools .jackson .databind .util .*;
2930
@@ -714,17 +715,14 @@ public ValueDeserializer<?> createArrayDeserializer(DeserializationContext ctxt,
714715 ArrayType type , BeanDescription .Supplier beanDescRef )
715716 {
716717 final DeserializationConfig config = ctxt .getConfig ();
717- JavaType elemType = type .getContentType ();
718+ final JavaType elemType = type .getContentType ();
718719
719720 // Very first thing: is deserializer hard-coded for elements?
720721 @ SuppressWarnings ("unchecked" )
721- ValueDeserializer <Object > contentDeser = (ValueDeserializer <Object >) elemType .getValueHandler ();
722+ final ValueDeserializer <Object > contentDeser = (ValueDeserializer <Object >) elemType .getValueHandler ();
722723 // Then optional type info: if type has been resolved, we may already know type deserializer:
723- TypeDeserializer elemTypeDeser = (TypeDeserializer ) elemType .getTypeHandler ();
724- // but if not, may still be possible to find:
725- if (elemTypeDeser == null ) {
726- elemTypeDeser = ctxt .findTypeDeserializer (elemType );
727- }
724+ final TypeDeserializer elemTypeDeser = _findContentTypeDeserializer (ctxt , elemType );
725+
728726 // 23-Nov-2010, tatu: Custom array deserializer?
729727 ValueDeserializer <?> deser = _findCustomArrayDeserializer (type ,
730728 config , beanDescRef , elemTypeDeser , contentDeser );
@@ -760,17 +758,11 @@ public ValueDeserializer<?> createArrayDeserializer(DeserializationContext ctxt,
760758 public ValueDeserializer <?> createCollectionDeserializer (DeserializationContext ctxt ,
761759 CollectionType type , BeanDescription .Supplier beanDescRef )
762760 {
763- JavaType contentType = type .getContentType ();
764- // Very first thing: is deserializer hard-coded for elements?
765- 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 );
766764 final DeserializationConfig config = ctxt .getConfig ();
767765
768- // Then optional type info: if type has been resolved, we may already know type deserializer:
769- TypeDeserializer contentTypeDeser = (TypeDeserializer ) contentType .getTypeHandler ();
770- // but if not, may still be possible to find:
771- if (contentTypeDeser == null ) {
772- contentTypeDeser = ctxt .findTypeDeserializer (contentType );
773- }
774766 // 23-Nov-2010, tatu: Custom deserializer?
775767 ValueDeserializer <?> deser = _findCustomCollectionDeserializer (type ,
776768 config , beanDescRef , contentTypeDeser , contentDeser );
@@ -853,18 +845,13 @@ protected CollectionType _mapAbstractCollectionType(JavaType type, Deserializati
853845 public ValueDeserializer <?> createCollectionLikeDeserializer (DeserializationContext ctxt ,
854846 CollectionLikeType type , BeanDescription .Supplier beanDescRef )
855847 {
856- JavaType contentType = type .getContentType ();
848+ final JavaType contentType = type .getContentType ();
857849 // Very first thing: is deserializer hard-coded for elements?
858850 @ SuppressWarnings ("unchecked" )
859851 ValueDeserializer <Object > contentDeser = (ValueDeserializer <Object >) contentType .getValueHandler ();
860852 final DeserializationConfig config = ctxt .getConfig ();
853+ final TypeDeserializer contentTypeDeser = _findContentTypeDeserializer (ctxt , contentType );
861854
862- // Then optional type info: if type has been resolved, we may already know type deserializer:
863- TypeDeserializer contentTypeDeser = (TypeDeserializer )contentType .getTypeHandler ();
864- // but if not, may still be possible to find:
865- if (contentTypeDeser == null ) {
866- contentTypeDeser = ctxt .findTypeDeserializer (contentType );
867- }
868855 ValueDeserializer <?> deser = _findCustomCollectionLikeDeserializer (type , config , beanDescRef ,
869856 contentTypeDeser , contentDeser );
870857 if (deser != null ) {
@@ -889,8 +876,8 @@ public ValueDeserializer<?> createMapDeserializer(DeserializationContext ctxt,
889876 MapType type , BeanDescription .Supplier beanDescRef )
890877 {
891878 final DeserializationConfig config = ctxt .getConfig ();
892- JavaType keyType = type .getKeyType ();
893- JavaType contentType = type .getContentType ();
879+ final JavaType keyType = type .getKeyType ();
880+ final JavaType contentType = type .getContentType ();
894881
895882 // First: is there annotation-specified deserializer for values?
896883 @ SuppressWarnings ("unchecked" )
@@ -899,11 +886,7 @@ public ValueDeserializer<?> createMapDeserializer(DeserializationContext ctxt,
899886 // Ok: need a key deserializer (null indicates 'default' here)
900887 KeyDeserializer keyDes = (KeyDeserializer ) keyType .getValueHandler ();
901888 // Then optional type info; either attached to type, or resolved separately:
902- TypeDeserializer contentTypeDeser = (TypeDeserializer ) contentType .getTypeHandler ();
903- // but if not, may still be possible to find:
904- if (contentTypeDeser == null ) {
905- contentTypeDeser = ctxt .findTypeDeserializer (contentType );
906- }
889+ final TypeDeserializer contentTypeDeser = _findContentTypeDeserializer (ctxt , contentType );
907890
908891 // 23-Nov-2010, tatu: Custom deserializer?
909892 ValueDeserializer <?> deser = _findCustomMapDeserializer (type , config , beanDescRef ,
@@ -1007,8 +990,8 @@ protected MapType _mapAbstractMapType(JavaType type, DeserializationConfig confi
1007990 public ValueDeserializer <?> createMapLikeDeserializer (DeserializationContext ctxt ,
1008991 MapLikeType type , BeanDescription .Supplier beanDescRef )
1009992 {
1010- JavaType keyType = type .getKeyType ();
1011- JavaType contentType = type .getContentType ();
993+ final JavaType keyType = type .getKeyType ();
994+ final JavaType contentType = type .getContentType ();
1012995 final DeserializationConfig config = ctxt .getConfig ();
1013996
1014997 // First: is there annotation-specified deserializer for values?
@@ -1023,11 +1006,7 @@ public ValueDeserializer<?> createMapLikeDeserializer(DeserializationContext ctx
10231006 }
10241007 */
10251008 // Then optional type info; either attached to type, or resolve separately:
1026- TypeDeserializer contentTypeDeser = (TypeDeserializer ) contentType .getTypeHandler ();
1027- // but if not, may still be possible to find:
1028- if (contentTypeDeser == null ) {
1029- contentTypeDeser = ctxt .findTypeDeserializer (contentType );
1030- }
1009+ final TypeDeserializer contentTypeDeser = _findContentTypeDeserializer (ctxt , contentType );
10311010 ValueDeserializer <?> deser = _findCustomMapLikeDeserializer (type , config ,
10321011 beanDescRef , keyDes , contentTypeDeser , contentDeser );
10331012 if (deser != null ) {
@@ -1139,11 +1118,7 @@ public ValueDeserializer<?> createReferenceDeserializer(DeserializationContext c
11391118 @ SuppressWarnings ("unchecked" )
11401119 ValueDeserializer <Object > contentDeser = (ValueDeserializer <Object >) contentType .getValueHandler ();
11411120 final DeserializationConfig config = ctxt .getConfig ();
1142- // Then optional type info: if type has been resolved, we may already know type deserializer:
1143- TypeDeserializer contentTypeDeser = (TypeDeserializer ) contentType .getTypeHandler ();
1144- if (contentTypeDeser == null ) { // or if not, may be able to find:
1145- contentTypeDeser = ctxt .findTypeDeserializer (contentType );
1146- }
1121+ final TypeDeserializer contentTypeDeser = _findContentTypeDeserializer (ctxt , contentType );
11471122 ValueDeserializer <?> deser = _findCustomReferenceDeserializer (type , config , beanDescRef ,
11481123 contentTypeDeser , contentDeser );
11491124
@@ -1738,6 +1713,24 @@ protected boolean _hasCreatorAnnotation(MapperConfig<?> config,
17381713 return false ;
17391714 }
17401715
1716+ // @since 3.1
1717+ protected TypeDeserializer _findContentTypeDeserializer (DeserializationContext ctxt ,
1718+ JavaType contentType )
1719+ {
1720+ // Then optional type info: if type has been resolved, we may already know type deserializer:
1721+ TypeDeserializer contentTypeDeser = (TypeDeserializer ) contentType .getTypeHandler ();
1722+ // [databind#1654]: @JsonTypeInfo(use = Id.NONE) should not apply type deserializer
1723+ // when custom content deserializer is specified via @JsonDeserialize(contentUsing = ...)
1724+ if (contentTypeDeser instanceof NoOpTypeDeserializer ) {
1725+ return null ;
1726+ }
1727+ if (contentTypeDeser == null ) {
1728+ // but if not, may still be possible to find:
1729+ contentTypeDeser = ctxt .findTypeDeserializer (contentType );
1730+ }
1731+ return contentTypeDeser ;
1732+ }
1733+
17411734 /*
17421735 /**********************************************************************
17431736 /* Helper classes
0 commit comments