Select ambiguous write method based on read method (matching its return type)

Also avoids unnecessary checks in name-based PropertyDescriptor constructor.

See gh-29320
This commit is contained in:
Juergen Hoeller
2022-10-18 16:17:03 +02:00
parent 33023b240f
commit 4b0bf16389
3 changed files with 72 additions and 25 deletions

View File

@@ -153,6 +153,16 @@ class BeanWrapperTests extends AbstractPropertyAccessorTests {
assertThat(accessor.getPropertyValue("object")).isEqualTo(8);
}
@Test
void setterOverload() {
SetterOverload target = new SetterOverload();
BeanWrapper accessor = createAccessor(target);
accessor.setPropertyValue("object", "a String");
assertThat(target.value).isEqualTo("a String");
assertThat(target.getObject()).isEqualTo("a String");
assertThat(accessor.getPropertyValue("object")).isEqualTo("a String");
}
@Test
void propertyDescriptors() throws Exception {
TestBean target = new TestBean();
@@ -348,6 +358,24 @@ class BeanWrapperTests extends AbstractPropertyAccessorTests {
}
public static class SetterOverload {
public String value;
public void setObject(Integer length) {
this.value = length.toString();
}
public void setObject(String object) {
this.value = object;
}
public String getObject() {
return this.value;
}
}
public static class GetterWithOptional {
public TestBean value;