Skip to content

Commit fe17f8d

Browse files
committed
BeanWrapperImpl.setBeanInstance correctly exposes root object
Issue: SPR-14474 (cherry picked from commit 938b56c)
1 parent b583aa1 commit fe17f8d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
9494

9595
private String nestedPath = "";
9696

97-
private Object rootObject;
97+
Object rootObject;
9898

9999
/**
100100
* Map with cached nested Accessors: nested path -> Accessor instance.
@@ -914,11 +914,9 @@ else if (Map.class.isAssignableFrom(type)) {
914914
return BeanUtils.instantiate(type);
915915
}
916916
}
917-
catch (Exception ex) {
918-
// TODO: Root cause exception context is lost here; just exception message preserved.
919-
// Should we throw another exception type that preserves context instead?
917+
catch (Throwable ex) {
920918
throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + name,
921-
"Could not instantiate property type [" + type.getName() + "] to auto-grow nested property path: " + ex);
919+
"Could not instantiate property type [" + type.getName() + "] to auto-grow nested property path", ex);
922920
}
923921
}
924922

spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ private BeanWrapperImpl(Object object, String nestedPath, BeanWrapperImpl parent
141141
*/
142142
public void setBeanInstance(Object object) {
143143
this.wrappedObject = object;
144+
this.rootObject = object;
144145
this.typeConverterDelegate = new TypeConverterDelegate(this, this.wrappedObject);
145146
setIntrospectionClass(object.getClass());
146147
}

0 commit comments

Comments
 (0)