@@ -120,10 +120,36 @@ public TypeDeserializer buildTypeDeserializer(DeserializationConfig config,
120
120
121
121
TypeIdResolver idRes = idResolver (config , baseType , subtypes , false , true );
122
122
123
- JavaType defaultImpl ;
123
+ JavaType defaultImpl = defineDefaultImpl ( config , baseType ) ;
124
124
125
+ // First, method for converting type info to type id:
126
+ switch (_includeAs ) {
127
+ case WRAPPER_ARRAY :
128
+ return new AsArrayTypeDeserializer (baseType , idRes ,
129
+ _typeProperty , _typeIdVisible , defaultImpl );
130
+ case PROPERTY :
131
+ case EXISTING_PROPERTY : // as per [#528] same class as PROPERTY
132
+ return new AsPropertyTypeDeserializer (baseType , idRes ,
133
+ _typeProperty , _typeIdVisible , defaultImpl , _includeAs );
134
+ case WRAPPER_OBJECT :
135
+ return new AsWrapperTypeDeserializer (baseType , idRes ,
136
+ _typeProperty , _typeIdVisible , defaultImpl );
137
+ case EXTERNAL_PROPERTY :
138
+ return new AsExternalTypeDeserializer (baseType , idRes ,
139
+ _typeProperty , _typeIdVisible , defaultImpl );
140
+ }
141
+ throw new IllegalStateException ("Do not know how to construct standard type serializer for inclusion type: " +_includeAs );
142
+ }
143
+
144
+ protected JavaType defineDefaultImpl (DeserializationConfig config , JavaType baseType ) {
145
+ JavaType defaultImpl ;
125
146
if (_defaultImpl == null ) {
126
- defaultImpl = null ;
147
+ //Fis of issue #955
148
+ if (config .isEnabled (DeserializationFeature .USE_BASE_TYPE_AS_DEFAULT ) && !baseType .isAbstract ()) {
149
+ defaultImpl = baseType ;
150
+ } else {
151
+ defaultImpl = null ;
152
+ }
127
153
} else {
128
154
// 20-Mar-2016, tatu: It is important to do specialization go through
129
155
// TypeFactory to ensure proper resolution; with 2.7 and before, direct
@@ -132,7 +158,7 @@ public TypeDeserializer buildTypeDeserializer(DeserializationConfig config,
132
158
// if so, need to add explicit checks for marker types. Not ideal, but
133
159
// seems like a reasonable compromise.
134
160
if ((_defaultImpl == Void .class )
135
- || (_defaultImpl == NoClass .class )) {
161
+ || (_defaultImpl == NoClass .class )) {
136
162
defaultImpl = config .getTypeFactory ().constructType (_defaultImpl );
137
163
} else {
138
164
if (baseType .hasRawClass (_defaultImpl )) { // common enough to check
@@ -156,24 +182,7 @@ public TypeDeserializer buildTypeDeserializer(DeserializationConfig config,
156
182
}
157
183
}
158
184
}
159
-
160
- // First, method for converting type info to type id:
161
- switch (_includeAs ) {
162
- case WRAPPER_ARRAY :
163
- return new AsArrayTypeDeserializer (baseType , idRes ,
164
- _typeProperty , _typeIdVisible , defaultImpl );
165
- case PROPERTY :
166
- case EXISTING_PROPERTY : // as per [#528] same class as PROPERTY
167
- return new AsPropertyTypeDeserializer (baseType , idRes ,
168
- _typeProperty , _typeIdVisible , defaultImpl , _includeAs );
169
- case WRAPPER_OBJECT :
170
- return new AsWrapperTypeDeserializer (baseType , idRes ,
171
- _typeProperty , _typeIdVisible , defaultImpl );
172
- case EXTERNAL_PROPERTY :
173
- return new AsExternalTypeDeserializer (baseType , idRes ,
174
- _typeProperty , _typeIdVisible , defaultImpl );
175
- }
176
- throw new IllegalStateException ("Do not know how to construct standard type serializer for inclusion type: " +_includeAs );
185
+ return defaultImpl ;
177
186
}
178
187
179
188
/*
0 commit comments