Skip to content

Commit

Permalink
Exception for OSIV deferred close with async requests
Browse files Browse the repository at this point in the history
OSIV deferred close mode is not supported with async requests and is
unlikely to be what's the desired. This change adds an exception with
a message stating this.

Issue: SPR-8517
  • Loading branch information
rstoyanchev committed May 4, 2012
1 parent 158b3c6 commit 6cca57a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Expand Up @@ -218,6 +218,9 @@ protected void doFilterInternal(
closeSession(sessionHolder.getSession(), sessionFactory);
}
else {
if (chain.isAsyncStarted()) {
throw new IllegalStateException("Deferred close is not supported with async requests.");
}
// deferred close mode
SessionFactoryUtils.processDeferredClose(sessionFactory);
}
Expand Down
Expand Up @@ -193,8 +193,13 @@ public Object call() throws Exception {
*/
public void postHandleAsyncStarted(WebRequest request) {
String attributeName = getParticipateAttributeName();
if ((request.getAttribute(attributeName, WebRequest.SCOPE_REQUEST) == null) && isSingleSession()) {
TransactionSynchronizationManager.unbindResource(getSessionFactory());
if (request.getAttribute(attributeName, WebRequest.SCOPE_REQUEST) == null) {
if (isSingleSession()) {
TransactionSynchronizationManager.unbindResource(getSessionFactory());
}
else {
throw new IllegalStateException("Deferred close is not supported with async requests.");
}
}
}

Expand Down

0 comments on commit 6cca57a

Please sign in to comment.