Closed
Description
Geir H. Pettersen opened SPR-5512 and commented
If you are working with a prototype bean that has a list setter, the beanfactory is reusing the list if you use a shorthand creation of the list.
This results in a strange behavior. Any changes you make to the list in a bean created from the prototype will appear on all new versions of the prototype.
Example:
public class SomePrototype {
private List<String> aList = new ArrayList<String>();
public List<String> getAList() {
return aList;
}
public void setAList(List<String> aList) {
this.aList = aList;
}
}
<bean id="buggedPrototype" class="SomePrototype" scope="prototype">
<property name="AList" value="The one and only"/>
</bean>
<bean id="okPrototype" class="SomePrototype" scope="prototype">
<property name="AList">
<list>
<value>The one and only</value>
</list>
</property>
</bean>
Affects: 2.5.6
Attachments:
- spring-bug.zip (2.98 kB)
Referenced from: commits dc1edcc