when userStorageManager() is called recursively, provided a meaningful exception to the caller.

This commit is contained in:
Alexander Schwartz 2022-06-13 10:42:30 +02:00 committed by Hynek Mlnařík
parent 26198e4b0b
commit 3fe477885c

View file

@ -230,10 +230,20 @@ public class DefaultKeycloakSession implements KeycloakSession {
return groups();
}
private final ThreadLocal<Boolean> recursionPreventionUserStorageManager = new ThreadLocal<>();
@Override
@Deprecated
public UserProvider userStorageManager() {
return users();
if(recursionPreventionUserStorageManager.get() != null) {
throw new IllegalStateException("userStorageManager() is being called recursively. Please adjust your code according to the Keycloak 19 migration guide.");
}
try {
recursionPreventionUserStorageManager.set(Boolean.TRUE);
return users();
} finally {
recursionPreventionUserStorageManager.remove();
}
}
@Override