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

PropertyPlaceholderConfigurer doesn't replace placeholders in map element bean reference [SPR-4846] #9522

Closed
spring-projects-issues opened this issue May 22, 2008 · 5 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Sergey Ponomarev opened SPR-4846 and commented

<bean id="myBean2" class="my.PropsHolder">
<property name="props1"><map>
<!--don't work--/> <entry key="${namespace}1" value-ref="${namespace}.myBean"/>
<!--don't work--/> <entry key="${namespace}"><ref bean="${namespace}.myBean"/> </entry>
</map></property>
<property name="props2"><list>
<!--works --/> <ref bean="${namespace}.myBean"/>
</list></property>
<property name="props3"><set>
<!--works --/> <ref bean="${namespace}.myBean"/>
</set></property>
<!--works --/> <property name="bean" ref="${namespace}.myBean"/>
</bean>


Affects: 2.5.4

Attachments:

@spring-projects-issues
Copy link
Collaborator Author

Sergey Ponomarev commented

stacktrace:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '${namespace}.myBean' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:387)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:968)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
... 25 more

@spring-projects-issues
Copy link
Collaborator Author

Sergey Ponomarev commented

Found error.
BeanDefinitionVisitor.resolveValue changes value of argument:
typedStringValue.setValue(visitedString);

I think this is an error, as code in BeanDefinitionVisitor.visitMap expects argument to be unchanged

@spring-projects-issues
Copy link
Collaborator Author

Sergey Ponomarev commented

Corrected TypedStringValue resolving

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I've fixed this in a slightly different fashion: PropertyPlaceholderConfigurer correctly manages resolution of set entries and map keys with modified hash code now. TypedStringValues are a typical example there, but BeanDefinition objects etc would be affected as well when used as set entry or map key. As a consequence, BeanDefinitionVisitor explicitly calculates and compares hash codes now, updating the set/map content accordingly when necessary.

This will be available in tonight' s 2.5.5 snapshot (http://static.springframework.org/downloads/nightly/snapshot-download.php?project=SPR). Please give it an early try if you have the chance, and let us know whether it works for you!

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Sergey Ponomarev commented

Test case passed.
Smoke tests on application didn't reveal errors.
Thanks for quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants