Skip to content

Couple of ExtendedBeanInfoTests failing on Java 7 [SPR-9007] #13646

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits 4a8be69, 0ee1256

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions