@@ -438,20 +438,27 @@ public JsonDeserializer<Object> buildThrowableDeserializer(DeserializationContex
438
438
}
439
439
AnnotatedMethod am = beanDesc .findMethod ("initCause" , INIT_CAUSE_PARAMS );
440
440
if (am != null ) { // should never be null
441
- // [databind#3497]: must consider possible PropertyNamingStrategy
442
- String name = "cause" ;
443
- PropertyNamingStrategy pts = config .getPropertyNamingStrategy ();
444
- if (pts != null ) {
445
- name = pts .nameForSetterMethod (config , am , "cause" );
446
- }
447
- SimpleBeanPropertyDefinition propDef = SimpleBeanPropertyDefinition .construct (ctxt .getConfig (), am ,
448
- new PropertyName (name ));
449
- SettableBeanProperty prop = constructSettableProperty (ctxt , beanDesc , propDef ,
450
- am .getParameterType (0 ));
451
- if (prop != null ) {
452
- // 21-Aug-2011, tatus: We may actually have found 'cause' property
453
- // to set... but let's replace it just in case, otherwise can end up with odd errors.
454
- builder .addOrReplaceProperty (prop , true );
441
+ SettableBeanProperty causeCreatorProp = builder .findProperty (PropertyName .construct ("cause" ));
442
+ // [databind#4827] : Consider case where sub-classed `Exception` has `JsonCreator` with `cause` parameter
443
+ if (causeCreatorProp instanceof CreatorProperty ) {
444
+ // Set fallback-setter as null, so `fixAccess()` does not happen during build
445
+ ((CreatorProperty ) causeCreatorProp ).setFallbackSetter (null );
446
+ } else {
447
+ // [databind#3497]: must consider possible PropertyNamingStrategy
448
+ String name = "cause" ;
449
+ PropertyNamingStrategy pts = config .getPropertyNamingStrategy ();
450
+ if (pts != null ) {
451
+ name = pts .nameForSetterMethod (config , am , "cause" );
452
+ }
453
+ SimpleBeanPropertyDefinition propDef = SimpleBeanPropertyDefinition .construct (ctxt .getConfig (), am ,
454
+ new PropertyName (name ));
455
+ SettableBeanProperty prop = constructSettableProperty (ctxt , beanDesc , propDef ,
456
+ am .getParameterType (0 ));
457
+ if (prop != null ) {
458
+ // 21-Aug-2011, tatus: We may actually have found 'cause' property
459
+ // to set... but let's replace it just in case, otherwise can end up with odd errors.
460
+ builder .addOrReplaceProperty (prop , true );
461
+ }
455
462
}
456
463
}
457
464
// update builder now that all information is in?
0 commit comments