-
Couldn't load subscription status.
- Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid
Description
Szczepan Kuzniarz opened SPR-8351 and commented
Using lookup-method in child bean definition produces non-deterministic behaviour. In the following example:
public class Parent {
public Object getSomething() {
// method injection
return null;
}
public void testMe() {
System.out.println(getSomething());
}
}
public class Child extends Parent {
}
public class ParentSomething {
public String toString() {
return "parent";
}
}
public class ChildSomething {
public String toString() {
return "child";
}
}
<bean id="parentSomething" class="ParentSomething"/>
<bean id="childSomething" class="ChildSomething"/>
<bean id="parentService" class="Parent">
<lookup-method name="getSomething" bean="parentSomething"/>
</bean>
<bean id="childService" class="Child" parent="parentService">
<lookup-method name="getSomething" bean="childSomething"/>
</bean>the result of testMe method called on childService bean is random: in Spring 2.0.2 and earlier childService getSomething method is called, ane in Spring 2.0.3 and later parentService getSomething method is called. This is caused by MethodOverrides class storing MethodOveride instances in HashSet (which doesn't guarantee any particular order of elements). In my opinion the most specific lookup-method (childService in the example above) should be used.
Affects: 3.0.5
Issue Links:
- Method lookup doesn't allow for overriding definitions in parent bean [SPR-13388] #17969 Method lookup doesn't allow for overriding definitions in parent bean
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid