Merge pull request #611 from mposolda/master

Fix transaction handling in KeycloakModelUtils.runJobInTransaction. Star...
This commit is contained in:
Marek Posolda 2014-08-11 13:53:04 +02:00
commit c57c264d91
2 changed files with 5 additions and 1 deletions

View file

@ -156,10 +156,12 @@ public final class KeycloakModelUtils {
tx.commit();
}
}
} finally {
} catch (RuntimeException re) {
if (tx.isActive()) {
tx.rollback();
}
throw re;
} finally {
session.close();
}
}

View file

@ -15,6 +15,7 @@ import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.services.DefaultKeycloakSessionFactory;
import org.keycloak.services.managers.ApplianceBootstrap;
import org.keycloak.services.managers.BruteForceProtector;
import org.keycloak.services.managers.PeriodicSyncManager;
import org.keycloak.services.managers.RealmManager;
import org.keycloak.services.managers.TokenManager;
import org.keycloak.services.resources.admin.AdminRoot;
@ -148,6 +149,7 @@ public class KeycloakApplication extends Application {
TimerProvider timer = sessionFactory.create().getProvider(TimerProvider.class);
timer.schedule(new ScheduledTaskRunner(sessionFactory, new ClearExpiredAuditEvents()), interval, "ClearExpiredAuditEvents");
timer.schedule(new ScheduledTaskRunner(sessionFactory, new ClearExpiredUserSessions()), interval, "ClearExpiredUserSessions");
new PeriodicSyncManager().bootstrap(sessionFactory, timer);
}
public KeycloakSessionFactory getSessionFactory() {