Skip to content

Regression in 4.0.0 - A scoped-proxy bean cannot override another bean [SPR-11229] #15854

Closed
@spring-projects-issues

Description

@spring-projects-issues

Francisco Lozano opened SPR-11229 and commented

It seems the behavior between 4.0.0.RELEASE and 3.2.5.RELEASE has changed with regard to bean overrides.

In the sample project (https://github.com/flozano/spring-override-behavior-changed) there is a singleton bean with a "sayHello" method, which returns "Hello "+name.

The original bean is configured thru Java Config in the AppConfiguration class.

The overriding bean is configured thru overridingApplicationContext.xml.

There is a test that checks that the correct string is returned for each bean ("Hello Lisa" for the original not-overriden app-ctx, "Hello Maria" for the overriden one).

  • If Spring 3.2.5.RELEASE is used in the pom.xml, the test always passes.
  • If Spring 4.0.0.RELEASE is used in the pom.xml and the overriding bean is a scoped-proxy, the test fails.
  • If Spring 4.0.0.RELEASE is used in the pom.xml and the overriding bean is NOT a scoped-proxy, the test passes.
  • Changing the scope of the overriding bean or the original bean has no effect in the results
  • Making the original bean also a scoped-proxy has no effect either
  • Configuring the original bean with XML instead of Java Config makes it work (???): removing the component-scan and adding this to originalApplicationContext.xml instead makes it work:
<bean id="theService" class="com.flozano.testbeanoverride.impl.TheServiceBean"
     scope="singleton" p:name="Lisa">
</bean>

Affects: 4.0 GA

Reference URL: https://github.com/flozano/spring-override-behavior-changed

Issue Links:

Referenced from: commits 61a3d04

1 votes, 3 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions