diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java b/org.springframework.beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java index 3b0dd4ccbdd4..ef9a3a94145a 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java @@ -219,7 +219,9 @@ private void addOrUpdatePropertyDescriptor(PropertyDescriptor pd, String propert } } // update the existing descriptor's write method - if (writeMethod != null) { + if (writeMethod != null + && !(existingPD instanceof IndexedPropertyDescriptor && + !writeMethod.getParameterTypes()[0].isArray())) { existingPD.setWriteMethod(writeMethod); } diff --git a/org.springframework.beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java b/org.springframework.beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java index 8111fdb237d4..ea4e783305ce 100644 --- a/org.springframework.beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java +++ b/org.springframework.beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java @@ -742,16 +742,28 @@ public boolean isTargetMethod() { assertThat(hasWriteMethodForProperty(ebi, "targetMethod"), is(false)); } - static class X { - public boolean isTargetMethod() { - return false; + @Test + public void cornerSpr8937() throws IntrospectionException { + @SuppressWarnings("unused") class A { + public void setAddress(String addr){ } + public void setAddress(int index, String addr) { } + public String getAddress(int index){ return null; } } - } - static class Y extends X { - @Override - public boolean isTargetMethod() { - return false; + { // baseline. ExtendedBeanInfo needs to behave exactly like the following + BeanInfo bi = Introspector.getBeanInfo(A.class); + assertThat(hasReadMethodForProperty(bi, "address"), is(false)); + assertThat(hasWriteMethodForProperty(bi, "address"), is(false)); + assertThat(hasIndexedReadMethodForProperty(bi, "address"), is(true)); + assertThat(hasIndexedWriteMethodForProperty(bi, "address"), is(true)); + } + { + ExtendedBeanInfo bi = new ExtendedBeanInfo(Introspector.getBeanInfo(A.class)); + assertThat(hasReadMethodForProperty(bi, "address"), is(false)); + assertThat(hasWriteMethodForProperty(bi, "address"), is(false)); + assertThat(hasIndexedReadMethodForProperty(bi, "address"), is(true)); + assertThat(hasIndexedWriteMethodForProperty(bi, "address"), is(true)); } } + }