<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=skaffman" rel="nofollow">Kenny MacLeod</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-4677?redirect=false" rel="nofollow">SPR-4677</a></strong> and commented</p>
<p dir="auto">In some cases, I would like to be able to more tightly bind a controller's exception handling to the controller itself.  I am imagining an <code class="notranslate">@ExceptionHandler</code> annotation which can be added to a controller's methods, which would be invoked by the framework if the <code class="notranslate">@RequestMapping-annotated</code> handler methods throw an exception.  These annotated methods would be used in preference to the context-wide ExceptionResolvers.</p>
<p dir="auto">This would be particularly useful in controllers with multiple <code class="notranslate">@RequestMapping</code> methods, all of which have related exception handling requirements, but which are specific to the controller.  Handling this sort of complex exception handling logic in a context-wide ExceptionResolver is decoupling things too much from the source of the exceptions.</p>
<p dir="auto">Thoughts?</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5.3</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="398093725" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10236" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10236/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10236">#10236</a> Annotation for exception handling inside annotation based Controllers (<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="398094165" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10304" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10304/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10304">#10304</a> Portlet-version of <code class="notranslate">@ExceptionHandler</code></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-projects/spring-framework/commit/f09f4e8dd2f167030204caecfa4a1ae720d8ecfe/hovercard" href="https://github.com/spring-projects/spring-framework/commit/f09f4e8dd2f167030204caecfa4a1ae720d8ecfe"><tt>f09f4e8</tt></a></p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=katentim" rel="nofollow">Tim Nolan</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-403?redirect=false" rel="nofollow">SPR-403</a></strong> and commented</p>
<p dir="auto">Spring constructor-arg comments state:</p>
<p dir="auto">"NOTE: it is highly recommended to use the index attribute, in Spring up<br>
to and including 1.1. The constructor matcher is extremely greedy in<br>
matching args without an index, to the point of duplicating supplied args<br>
to fill in unspecified constructor args, if they are compatible (i.e. one<br>
single String arg will match a constructor with two String args, etc.).<br>
The matcher should be less agressive in a future version."</p>
<p dir="auto">This doesn't appear to be the case. This only occurs with autowiring. Here's a test case demonstating that a supplied argument isn't duplicated:</p>
<p dir="auto">&lt;bean id="exampleBean" class="dateformat.Test"&gt;<br>
&lt;constructor-arg type="java.lang.Boolean"&gt;&lt;value&gt;true&lt;/value&gt;&lt;/constructor-arg&gt;<br>
&lt;/bean&gt;<br>
public class Test {<br>
public Test(Boolean b, Boolean b2) {<br>
System.out.println("b='" + b + "'");<br>
System.out.println("b2='" + b2 + "'");<br>
}<br>
}</p>
<hr>
<p dir="auto">No further details from <a href="https://jira.spring.io/browse/SPR-403?redirect=false" rel="nofollow">SPR-403</a></p>