<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=mzupper@boscovs.com" rel="nofollow">Mike Zupper</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-794?redirect=false" rel="nofollow">SPR-794</a></strong> and commented</p>
<p dir="auto">Here is the scenerio:</p>
<ul dir="auto">
<li>MyAccountForm extends SimpleFormController</li>
<li>MyAccountValidator implements Validator</li>
</ul>
<p dir="auto">Within MyAccountForm I override the following method:</p>
<p dir="auto">protected ModelAndView onSubmit(HttpServletRequest request,<br>
HttpServletResponse response,<br>
Object command,<br>
BindException errors)<br>
throws Exception</p>
<p dir="auto">with proper validation and no errors, The framework should call the "onSubmit" method with the defined signature but it does not. If  I override, the following method:</p>
<p dir="auto">protected ModelAndView onSubmit(Object command)<br>
throws Exception</p>
<hr>
<p dir="auto">it calls the "onSubmit" method properly.</p>
<p dir="auto">I need to access the HTTP request to set session data.</p>
<p dir="auto">I used my IDE's debugger to trace it down and I could not find any reason why that above onSubmit method does not work... Any Ideas????</p>
<p dir="auto">Please see issue# <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398054880" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/5420" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/5420/hovercard" href="https://github.com/spring-projects/spring-framework/issues/5420">#5420</a> for similar problem.</p>
<p dir="auto">Thanks,</p>
<p dir="auto">Mike Zupper (<a href="mailto:mzupper@boscovs.com">mzupper@boscovs.com</a>)</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 1.1.3, 1.1.4, 1.1.5</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/10595/SimpleFormController.java" rel="nofollow">SimpleFormController.java</a> (<em>16.39 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="398054880" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/5420" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/5420/hovercard" href="https://github.com/spring-projects/spring-framework/issues/5420">#5420</a> After a successfull validation Spring does not call the onSubmit method with signature of (request, response,object, bindexception) (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=krosenvold" rel="nofollow">Kristian Rosenvold</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-5863?redirect=false" rel="nofollow">SPR-5863</a></strong> and commented</p>
<h4 dir="auto">Status Quo</h4>
<p dir="auto">Newer versions of JUnit support concurrent test execution; however, the <em>Spring TestContext Framework</em> is not designed for concurrency.</p>
<h4 dir="auto">Proposed Solution</h4>
<p dir="auto">The enclosed fixes sharpen focus on concurrency (including making mutable state much more distinct from immutable state), increasing separation between data for each test method run and the class they are being run on.</p>
<p dir="auto">The patch consists of a failing test (patch 1) and a fix (patch 2), including several new tests. If you choose to apply the patch with the failing test, you must revert this before applying the fix (failing test is contained in fix patch). The included failing test may not produce concurrency issues (fail) in all cases and on all hardware platforms. They have been known to fail consistently on 3 different machines, usually upon first run.</p>
<h5 dir="auto">Details of the Patch</h5>
<p dir="auto">The patch contains minor changes to the <code class="notranslate">ContextLoader</code> interface. The most significant changes have been made to the <code class="notranslate">TestContextManager</code> and <code class="notranslate">TestContext</code> classes.</p>
<p dir="auto">Additionally upon completing the functionality, I had multiple deadlocks in the JVM when running my real test suite. I solved this by using a Java 5 <code class="notranslate">ReentrantReadWriteLock</code> in the <code class="notranslate">RequestAttributes.getSessionMutex()</code> method. It really looks to me like the creation of this mutex should be moved to one of the loader filters, since it's always created as of this patch.</p>
<p dir="auto">Additionally, the patch contains a <code class="notranslate">MockContextLoader</code> that transfers attributes between threads. I'd really like you guys to check that code out before accepting it; there may be other smarter ways of doing this. It's only a part of the test code-base, but once it's included it sets a standard.</p>
<h4 dir="auto">Real-life Tests</h4>
<p dir="auto">The patch has been applied to a local version of Spring 3 that has been running stably with multi-core machines and multi-CPU servers too. We have been running a continuous build using parallel classes, methods, and a combination of both. This is a full-scale build that was adaptable to multi-threaded test execution. The application under test uses lots of web-scopes, etc.</p>
<h4 dir="auto">Proposed Documentation</h4>
<blockquote>
<p dir="auto"><strong>Parallel Test Execution</strong></p>
<p dir="auto">From version 3.0, Spring supports parallel test execution in the <em>Spring TestContext Framework</em>. Executing builds in parallel with JUnit is only supported in later versions of JUnit, and it is recommended to use at least JUnit 4.6 for this feature. Please also note that there's no guarantee your tests will run properly in parallel; a number of general concurrency issues have to be taken into account when executing tests in parallel. Your runner can usually let you choose between classes, methods, and a combination of both. Classes are usually the easiest to get working; "a combination of both" is the hardest. All three modes are supported.</p>
</blockquote>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0 M3</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/15764/1concurrencyFix2051.patch" rel="nofollow">1concurrencyFix2051.patch</a> (<em>77.48 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/15765/2tests2051.patch" rel="nofollow">2tests2051.patch</a> (<em>31.53 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/16722/3428_SPR5863.patch" rel="nofollow">3428_SPR5863.patch</a> (<em>53.32 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/15766/3dirtiesContext2051.patch" rel="nofollow">3dirtiesContext2051.patch</a> (<em>34.46 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/15500/completeFix.patch" rel="nofollow">completeFix.patch</a> (<em>189.66 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/15499/springFailingTest.patch" rel="nofollow">springFailingTest.patch</a> (<em>33.11 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="398159474" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/15263" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/15263/hovercard" href="https://github.com/spring-projects/spring-framework/issues/15263">#15263</a> Debug logging for DependencyInjectionTestExecutionListener breaks injection for parallel tests (<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="398191558" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/18684" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/18684/hovercard" href="https://github.com/spring-projects/spring-framework/issues/18684">#18684</a> Problems running integration tests in parallel using SpringClassRule and SpringMethodRule (<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="398201682" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/19549" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/19549/hovercard" href="https://github.com/spring-projects/spring-framework/issues/19549">#19549</a> using ParallelComputer to test spring test cases got error (<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="398173702" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/17028" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/17028/hovercard" href="https://github.com/spring-projects/spring-framework/issues/17028">#17028</a> Improve thread safety in Spring JUnit integration (<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="398116146" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13582" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13582/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13582">#13582</a> Test execution issue: for "shared" test contexts in multithreading</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398115629" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13499" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13499/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13499">#13499</a> <code class="notranslate">@DirtiesContext</code> does not destroy all cached singleton beans</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398158847" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/15166" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/15166/hovercard" href="https://github.com/spring-projects/spring-framework/issues/15166">#15166</a> Do not serialize ApplicationContext creation in the TestContext framework</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398108341" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12343" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12343/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12343">#12343</a> Use soft or weak references for context caching in the TestContext framework</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398110759" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12710" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12710/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12710">#12710</a> Limit size of context cache in the TestContext framework</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/e822e4cbe87b09b901eb2363bc884a635a96a01e/hovercard" href="https://github.com/spring-projects/spring-framework/commit/e822e4cbe87b09b901eb2363bc884a635a96a01e"><tt>e822e4c</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/3dc6f1133c1208d212220777fda585f3371f5cc0/hovercard" href="https://github.com/spring-projects/spring-framework/commit/3dc6f1133c1208d212220777fda585f3371f5cc0"><tt>3dc6f11</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/fbfad8695ecc9262f23fd31b0b425eca38b58d01/hovercard" href="https://github.com/spring-projects/spring-framework/commit/fbfad8695ecc9262f23fd31b0b425eca38b58d01"><tt>fbfad86</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/3e96cab0bb9e2861f9555f81117eb46098674f8e/hovercard" href="https://github.com/spring-projects/spring-framework/commit/3e96cab0bb9e2861f9555f81117eb46098674f8e"><tt>3e96cab</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/2699504cb8150d7be3e3a4033215acb8fbf1e851/hovercard" href="https://github.com/spring-projects/spring-framework/commit/2699504cb8150d7be3e3a4033215acb8fbf1e851"><tt>2699504</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/a10a8e56df80e6855d104d07010e6f1445100a61/hovercard" href="https://github.com/spring-projects/spring-framework/commit/a10a8e56df80e6855d104d07010e6f1445100a61"><tt>a10a8e5</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/ec7aefa8589d2baf0aea28eac6fd8baae1167de6/hovercard" href="https://github.com/spring-projects/spring-framework/commit/ec7aefa8589d2baf0aea28eac6fd8baae1167de6"><tt>ec7aefa</tt></a></p>
<p dir="auto">42 votes, 40 watchers</p>