Skip to content

Infinite loop in bean creation when placeholder used for bean name [SPR-5419] #10093

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

Closed
spring-projects-issues opened this issue Jan 19, 2009 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Dave Syer opened SPR-5419 and commented

If I use a placeholder to create the bean name alias from the name= attribute, there is an infinte loop in the bean creation (Spring never comes back from creating the application context). Example:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
xmlns:context="http://www.springframework.org/schema/context">

<bean id="string" name="${string.name}" class="java.lang.String">
	<constructor-arg value="${string.value}" />
</bean>

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
	<property name="properties">
		<value>
		string.value=foo
		string.name=string
		</value>
	</property>
</bean>

</beans>
If the placeholder is not used for the name= (or if the alias is different from the id) then everything is fine.


Affects: 2.5.6

Referenced from: commits eb1631f

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Good catch! We did check for alias/name equality when registering an alias but not after placeholder resolution of an alias value. Fixed as of 3.0 M2.

Juergen

@spring-projects-issues spring-projects-issues added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0 M2 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants