Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ protected void finished(Description description) {
* testing of several parallel session factories which can be used to simulate several servers
* running in parallel.
*/
public static KeycloakSessionFactory createKeycloakSessionFactory() {
public static synchronized KeycloakSessionFactory createKeycloakSessionFactory() {
int factoryIndex = FACTORY_COUNT.incrementAndGet();
String threadName = Thread.currentThread().getName();
CONFIG.reset();
Expand Down Expand Up @@ -553,11 +553,16 @@ public final void createEnvironment() {

@After
public final void cleanEnvironment() {
if (getFactory() == null) {
try {
if (getFactory() == null) {
reinitializeKeycloakSessionFactory();
}
setTimeOffset(0);
KeycloakModelUtils.runJobInTransaction(getFactory(), this::cleanEnvironment);
} catch (Exception e) {
LOG.warnf(e, "Failed to clean environment after test, reinitializing factory");
reinitializeKeycloakSessionFactory();
}
setTimeOffset(0);
KeycloakModelUtils.runJobInTransaction(getFactory(), this::cleanEnvironment);
}

protected static <T> Stream<T> getParameters(Class<T> clazz) {
Expand Down
Loading