@@ -260,10 +260,16 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo
260
260
if (potentialCreators .hasPropertiesBased ()) {
261
261
PotentialCreator primaryPropsBased = potentialCreators .propertiesBased ;
262
262
263
- // Start by assigning the primary (and only) properties-based creator
264
- _addSelectedPropertiesBasedCreator (ctxt , beanDesc , creators ,
265
- CreatorCandidate .construct (config .getAnnotationIntrospector (),
266
- primaryPropsBased .creator (), primaryPropsBased .propertyDefs ()));
263
+ // 12-Nov-2024, tatu: [databind#4777] We may have collected a 0-args Factory
264
+ // method; and if so, may need to "pull it out" as default creator
265
+ if (primaryPropsBased .paramCount () == 0 ) {
266
+ creators .setDefaultCreator (primaryPropsBased .creator ());
267
+ } else {
268
+ // Start by assigning the primary (and only) properties-based creator
269
+ _addSelectedPropertiesBasedCreator (ctxt , beanDesc , creators ,
270
+ CreatorCandidate .construct (config .getAnnotationIntrospector (),
271
+ primaryPropsBased .creator (), primaryPropsBased .propertyDefs ()));
272
+ }
267
273
}
268
274
269
275
// Continue with explicitly annotated delegating Creators
@@ -283,9 +289,10 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo
283
289
// First things first: the "default constructor" (zero-arg
284
290
// constructor; whether implicit or explicit) is NOT included
285
291
// in list of constructors, so needs to be handled separately.
286
- AnnotatedConstructor defaultCtor = beanDesc .findDefaultConstructor ();
287
- if (defaultCtor != null ) {
288
- if (!creators .hasDefaultCreator () || _hasCreatorAnnotation (config , defaultCtor )) {
292
+ // However, we may have added one for 0-args Factory method earlier, so:
293
+ if (!creators .hasDefaultCreator ()) {
294
+ AnnotatedConstructor defaultCtor = beanDesc .findDefaultConstructor ();
295
+ if (defaultCtor != null ) {
289
296
creators .setDefaultCreator (defaultCtor );
290
297
}
291
298
}
0 commit comments