diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.java b/spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.java index fbcac64f644e..30cdc55f53b0 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.java @@ -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); } diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewInterceptor.java b/spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewInterceptor.java index 7fdd1518955b..5eccff677beb 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewInterceptor.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewInterceptor.java @@ -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."); + } } }