Fix transaction handling in KeycloakModelUtils.runJobInTransaction. Start sync tasks for configured federation providers at startup

This commit is contained in:
mposolda 2014-08-11 13:51:44 +02:00
parent c4d5a4138c
commit 8ba7559cac
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() {