Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When we remove bean from the application context, its aliases must be cleared as well [SPR-16837] #21377

spring-projects-issues opened this issue May 17, 2018 · 1 comment
in: core status: waiting-for-triage


Copy link

@spring-projects-issues spring-projects-issues commented May 17, 2018

Artem Bilan opened SPR-16837 and commented

The simple test-case to reproduce:

public void aliasesConflict() {
	GenericApplicationContext applicationContext = new GenericApplicationContext();

	String beanName = "foo";
	String alias = "bar";

	applicationContext.registerBean(beanName, String.class);
	applicationContext.registerAlias(beanName, alias);


	applicationContext.registerBean("foo2", String.class);
	applicationContext.registerAlias("foo2", alias);


Ends up with an exception:

java.lang.IllegalStateException: Cannot register alias 'bar' for name 'foo2': It is already registered for name 'foo'.

	at org.springframework.core.SimpleAliasRegistry.registerAlias(

The point is: there is no a bean for that alias any more, so why do we keep it?


Affects: 5.0.6

Referenced from: pull request #1837

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 25, 2018

xin commented

It sames that:

When GenericApplicationContext.removeBeanDefinition(), it should remove this bean had register alias in SimpleAliasRegistry.aliasMap.

@spring-projects-issues spring-projects-issues added type: bug status: waiting-for-triage in: core and removed type: bug labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: core status: waiting-for-triage
None yet

No branches or pull requests

1 participant