Repository navigation
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement
Milestone
Description
Stevo Slavić opened SPR-9007 and commented
ExtendedBeanInfoTests.reproSpr8522 and some other tests fail when run with Java 7 (openjdk & oracle).
[junit] Testcase: reproSpr8522(org.springframework.beans.ExtendedBeanInfoTests): FAILED
[junit]
[junit] Expected: is <true>
[junit] got: <false>
[junit]
[junit] junit.framework.AssertionFailedError:
[junit] Expected: is <true>
[junit] got: <false>
[junit]
[junit] at org.springframework.beans.ExtendedBeanInfoTests.reproSpr8522(ExtendedBeanInfoTests.java:553)
[junit]
[junit]
[junit] Testcase: indexedReadAndNonStandardIndexedWrite(org.springframework.beans.ExtendedBeanInfoTests): FAILED
[junit]
[junit] Expected: is <true>
[junit] got: <false>
[junit]
[junit] junit.framework.AssertionFailedError:
[junit] Expected: is <true>
[junit] got: <false>
[junit]
[junit] at org.springframework.beans.ExtendedBeanInfoTests.indexedReadAndNonStandardIndexedWrite(ExtendedBeanInfoTests.java:436)
[junit]
[junit]
[junit] Testcase: indexedReadAndNonStandardWriteAndNonStandardIndexedWrite(org.springframework.beans.ExtendedBeanInfoTests): FAILED
[junit]
[junit] Expected: is <true>
[junit] got: <false>
[junit]
[junit] junit.framework.AssertionFailedError:
[junit] Expected: is <true>
[junit] got: <false>
[junit]
[junit] at org.springframework.beans.ExtendedBeanInfoTests.indexedReadAndNonStandardWriteAndNonStandardIndexedWrite(ExtendedBeanInfoTests.java:459)
Tests pass when run using Java 6 (openjdk). Looking at the source of Introspector, in getTargetPropertyInfo at least following has been changed:
from
} else if (argCount == 2) {
if (argTypes[0] == int.class && name.startsWith(SET_PREFIX)) {
pd = new IndexedPropertyDescriptor(this.beanClass, name.substring(3), null, null, null, method);
if (throwsException(method, PropertyVetoException.class)) {
pd.setConstrained(true);
}
}
}
to
} else if (argCount == 2) {
if (void.class.equals(resultType) && int.class.equals(argTypes[0]) && name.startsWith(SET_PREFIX)) {
pd = new IndexedPropertyDescriptor(this.beanClass, name.substring(3), null, null, null, method);
if (throwsException(method, PropertyVetoException.class)) {
pd.setConstrained(true);
}
}
}
It seems that non-standard indexed write methods like
public Object setFoos(int i, String foo) { return new Object(); }
are no longer supported - method has to return void.
After changing these setters to return void, tests would pass on both Java 6 and Java 7.
Affects: 3.1 GA
Issue Links:
- Overhaul non-void JavaBean write method support [SPR-10029] #14663 Overhaul non-void JavaBean write method support
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement
Activity
spring-projects-issues commentedon Feb 13, 2012
Chris Beams commented
spring-projects-issues commentedon Nov 25, 2012
Chris Beams commented
A general note to watchers of
ExtendedBeanInfo-related issues: #14663 is a major refactoring ofExtendedBeanInfoand overall support for non-void returning setter methods.If you have submitted a reproduction project with this issue, we have run it through its paces against these new changes, but we would like to ask you to do the same against your actual applications.
Please consider updating your dev or test builds to work against 3.1.4.BUILD-SNAPSHOT and/or 3.2.0.BUILD-SNAPSHOT to verify, and we would appreciate any feedback, even if it's to let us know that all is well. So that we can consolidate feedback, please add your comments to #14663, and mention the original issue(s) that you were watching.
Thanks!
Note also that testing against 3.1.4 is preferable to 3.2.0 because
ExtendedBeanInfois always in the code path in the latter, while in 3.2.0 we've optimized things such thatExtendedBeanInfois only in play for bean classes that have one or more non-void returning setter methods.