SEC-1369: Springbeans gets registered twice #1612

Closed
spring-issuemaster opened this Issue Jan 14, 2010 · 2 comments

1 participant

@spring-issuemaster

Jonas Hauenstein (Migrated from SEC-1369) said:

When Spring's beans-overriding property is set to false (bean overriding is forbidden), errors regarding duplicated beans are thrown (from Spring).

After some debugging, I found the source of this problem in the following (and similar) lines inside the spring-security-config module.

String id = pc.getReaderContext().registerWithGeneratedName(provider);
pc.registerBeanComponent(new BeanComponentDefinition(provider, id));

The problem is, that within the method registerWithGeneratedName, the method registerBeanDefinition is called (as the name says). This is also done when calling registerBeanComponent afterwards.

In my opinion, the solution is to replace the codelines above with:

String id = pc.getReaderContext().generateBeanName(provider);
pc.registerBeanComponent(new BeanComponentDefinition(provider, id));

The problematic code fragment can be found in different classes of the module multiple times.
Replacing all occurrences solved the problem on our test cases. Also, all the tests of the whole Spring Security framework were passed successfully.

I attach a patch which includes the modification that i have done.
This was created from / for the 3.0.0.RELEASE tag.

I hope, this can be helpful and will be integrated into the next release.

Cheers

Jonas

@spring-issuemaster

Luke Taylor said:

This is a good point - thanks for the patch. I've updated all the uses I could find where this pattern occurs and also changed the test context class to disallow bean overriding.

@spring-issuemaster

Jonas Hauenstein said:

You are more than welcome!
Also thank you for the fast fix of the issue. So we can use 3.0.1 as soon as it will be released without patching.
Cheers

@spring-issuemaster spring-issuemaster added this to the 3.0.1 milestone Feb 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment