KEYCLOAK-2577 Rollback session in KeycloakSessionServletFilter if not committed by KeycloakTransactionCommitter

This commit is contained in:
Stian Thorgersen 2016-03-03 08:59:19 +01:00
parent 402feb9710
commit 2edb7f6831

View file

@ -77,6 +77,12 @@ public class KeycloakSessionServletFilter implements Filter {
try {
filterChain.doFilter(servletRequest, servletResponse);
} finally {
// KeycloakTransactionCommitter is responsible for committing the transaction, but if an exception is thrown it's not invoked and transaction
// should be rolled back
if (session.getTransaction() != null && session.getTransaction().isActive()) {
session.getTransaction().rollback();
}
session.close();
ResteasyProviderFactory.clearContextData();
}