diff --git a/spring-beans/src/main/java/org/springframework/beans/SimpleBeanInfoFactory.java b/spring-beans/src/main/java/org/springframework/beans/SimpleBeanInfoFactory.java index 6719b156a510..75c9a699bb69 100644 --- a/spring-beans/src/main/java/org/springframework/beans/SimpleBeanInfoFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/SimpleBeanInfoFactory.java @@ -16,6 +16,7 @@ package org.springframework.beans; +import java.beans.BeanDescriptor; import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.PropertyDescriptor; @@ -52,6 +53,10 @@ public BeanInfo getBeanInfo(Class beanClass) throws IntrospectionException { PropertyDescriptorUtils.determineBasicProperties(beanClass); return new SimpleBeanInfo() { + @Override + public BeanDescriptor getBeanDescriptor() { + return new BeanDescriptor(beanClass); + } @Override public PropertyDescriptor[] getPropertyDescriptors() { return pds.toArray(PropertyDescriptorUtils.EMPTY_PROPERTY_DESCRIPTOR_ARRAY); diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java index 4766b6e2a745..c933699da38a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java @@ -77,6 +77,21 @@ void aliasedSetterThroughDefaultMethod() { assertThat(accessor.getPropertyValue("aliasedName")).isEqualTo("tom"); } + @Test + void replaceWrappedInstance() { + GetterBean target = new GetterBean(); + BeanWrapperImpl accessor = createAccessor(target); + accessor.setPropertyValue("name", "tom"); + assertThat(target.getAliasedName()).isEqualTo("tom"); + assertThat(accessor.getPropertyValue("aliasedName")).isEqualTo("tom"); + + target = new GetterBean(); + accessor.setWrappedInstance(target); + accessor.setPropertyValue("name", "tom"); + assertThat(target.getAliasedName()).isEqualTo("tom"); + assertThat(accessor.getPropertyValue("aliasedName")).isEqualTo("tom"); + } + @Test void setValidAndInvalidPropertyValuesShouldContainExceptionDetails() { TestBean target = new TestBean();