<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=sethladd" rel="nofollow">Seth Ladd</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-1247?redirect=false" rel="nofollow">SPR-1247</a></strong> and commented</p>
<p dir="auto">Hello again,</p>
<p dir="auto">As I was browsing the AbstractFormController source, I noticed what seemed to be some duplication of code.  It's quite possible this can be cleaned up a small bit.</p>
<p dir="auto">Inside handleRequestInternal, there is this logic:</p>
<p dir="auto">if (isSessionForm()) {<br>
HttpSession session = request.getSession(false);<br>
if (session == null || session.getAttribute(getFormSessionAttributeName(request)) == null) {<br>
return handleInvalidSubmit(request, response);<br>
}<br>
}</p>
<p dir="auto">Which is essentially duplicated in getCommand() of the same class.</p>
<p dir="auto">I'd like to propose that getCommand() throw some error-specific exceptions when the session doesn't exist, or when the form doesn't exist in the session.  This way, the code in handleRequestInternal can merely attempt a call to getCommand() and see if there are exceptions like NoExistingSessionException.  If handleRequestInternal sees that exception, it can then forward the call to handleInvalidSubmit().</p>
<p dir="auto">At this point, the checking of the session and the checking if the form bean is in the session is in two different places that are called twice in a row.  I think with just a bit of code moving, we can do the checking of the session once.</p>
<p dir="auto">Thanks!<br>
Seth</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 1.2.4</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=marceloverdijk" rel="nofollow">Marcel Overdijk</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9380?redirect=false" rel="nofollow">SPR-9380</a></strong> and commented</p>
<p dir="auto">I have the blow AppConfig class in my project:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@Configuration
@ComponentScan(basePackages = { &quot;my.project&quot; })
@PropertySource({ &quot;classpath:/META-INF/config.properties&quot;, &quot;classpath:/META-INF/config-${my.runtime.environment}.properties&quot; })
public class AppConfig {

	private static Log LOG = LogFactory.getLog(AppConfig.class);

	@Bean
	public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
		return new PropertySourcesPlaceholderConfigurer();
	}"><pre class="notranslate"><code class="notranslate">@Configuration
@ComponentScan(basePackages = { "my.project" })
@PropertySource({ "classpath:/META-INF/config.properties", "classpath:/META-INF/config-${my.runtime.environment}.properties" })
public class AppConfig {

	private static Log LOG = LogFactory.getLog(AppConfig.class);

	@Bean
	public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
		return new PropertySourcesPlaceholderConfigurer();
	}
</code></pre></div>
<p dir="auto">Resolving the ${my.runtime.environment} in the <code class="notranslate">@PropertySource</code> does not work anymore in Spring 3.1.1 while I was just upgrading from 3.1.0.<br>
The same code works fine in 3.1.0 but gives this error in 3.1.1:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Failed to load bean class: mt.project.config.AppConfig; nested exception is java.io.FileNotFoundException: class path resource [META-INF/config-${my.runtime.environment}.properties] cannot be opened because it does not exist"><pre class="notranslate"><code class="notranslate">Failed to load bean class: mt.project.config.AppConfig; nested exception is java.io.FileNotFoundException: class path resource [META-INF/config-${my.runtime.environment}.properties] cannot be opened because it does not exist
</code></pre></div>
<p dir="auto">The config file exists and the system property is set (I logged that as well), and just to mention it again. In 3.1.0 this works fine.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1.1</p>
<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="398117373" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13772" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13772/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13772">#13772</a> Fix regression in <code class="notranslate">@PropertySource</code> placeholder resolution (<em><strong>"duplicates"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398117311" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13766" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13766/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13766">#13766</a> <code class="notranslate">@PropertySource</code> annotation with multiple values and a name fails to register all property sources (<em><strong>"duplicates"</strong></em>)</li>
</ul>