<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=gizit" rel="nofollow">Gisbert van Rossum</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-6428?redirect=false" rel="nofollow">SPR-6428</a></strong> and commented</p>
<p dir="auto">When using 2 PropertyPlaceHolderConfigurers, placeholders declared (and given a value) in the first PPC are not resolved in the second PPC.</p>
<p dir="auto">&lt;bean id="configurer1" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;<br>
&lt;property name="properties"&gt;<br>
&lt;bean class="java.util.Properties"&gt;<br>
&lt;constructor-arg&gt;<br>
&lt;map&gt;<br>
&lt;entry key="resourceDirPlaceHolder"&gt;<br>
&lt;value&gt;myResourceDir&lt;/value&gt;<br>
&lt;/entry&gt;<br>
&lt;/map&gt;<br>
&lt;/constructor-arg&gt;<br>
&lt;/bean&gt;<br>
&lt;/property&gt;<br>
&lt;property name="order" value="1"/&gt;<br>
&lt;property name="ignoreUnresolvablePlaceholders" value="true"/&gt;<br>
&lt;/bean&gt;<br>
&lt;bean id="configurer2" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;<br>
&lt;property name="locations"&gt;<br>
&lt;list&gt;<br>
&lt;value&gt;classpath:${resourceDirPlaceHolder}/props.properties&lt;/value&gt;<br>
&lt;/list&gt;<br>
&lt;/property&gt;<br>
&lt;/bean&gt;</p>
<p dir="auto">this configuration results in:</p>
<p dir="auto">java.io.FileNotFoundException: class path resource [${resourceDirPlaceHolder}/props.properties] cannot be opened because it does not exist</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5.6</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/15954/multiplePPCs.zip" rel="nofollow">multiplePPCs.zip</a> (<em>4.84 kB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398094795" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10389" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10389/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10389">#10389</a> only the first PropertyPlaceHolderConfigurer is initialized. Others are not (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398094795" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10389" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10389/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10389">#10389</a> only the first PropertyPlaceHolderConfigurer is initialized. Others are not</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-attic/spring-framework-issues/commit/09aea36859bb0d806eb4085a2c154cb781bd8345/hovercard" href="https://github.com/spring-attic/spring-framework-issues/commit/09aea36859bb0d806eb4085a2c154cb781bd8345">spring-attic/spring-framework-issues@<tt>09aea36</tt></a></p>
<p dir="auto">2 votes, 2 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=profiprog" rel="nofollow">Milan Skuhra</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9322?redirect=false" rel="nofollow">SPR-9322</a></strong> and commented</p>
<p dir="auto">I tried to inject collection of beans (services) twice, into two beans (registers); and every register has injected different count of services.<br>
Proxied bean was missing in second injection. It happend when first injection occurs and injecting proxied bean isn't created yet.</p>
<p dir="auto">I debug it and found that method org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(..) has critical role in decision process if proxied bean will be injected or not.<br>
If first injection occurs and proxied bean is not created yet, then method isTypeMatch(..) check injection suitability according to bean definition. Of course the proxied bean must be created to complete injection but apparently nothing check if type criteria is still matching after creation. When second injection occurs instance is already available and method isTypeMatch(..) check injection suitability according to instance - because it's a proxy it can return different result (as was in my case).</p>
<p dir="auto">I attached simple project with one test case where this specific case is simulated. Of course there are many possibilities to fix it, but when somebody else accidentally configure something like this, it can be really hard to find where is the problem.</p>
<p dir="auto">I suggest to duplicate condition (about suitability of bean to be injected) also after its creation.<br>
If condition changes, exclude it from candidates and log some warning message.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1.1</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/19578/dependency-feature.tgz" rel="nofollow">dependency-feature.tgz</a> (<em>3.34 kB</em>)</li>
</ul>
<p dir="auto">2 votes, 2 watchers</p>