Ensure map storage providers are closed upon session close
Fixes: #14730
This commit is contained in:
parent
425b6b8df2
commit
36a1ce6a1a
2 changed files with 6 additions and 0 deletions
|
@ -108,6 +108,7 @@ public abstract class AbstractMapProviderFactory<T extends Provider, V extends A
|
|||
protected MapStorage<V, M> getStorage(KeycloakSession session) {
|
||||
ProviderFactory<MapStorageProvider> storageProviderFactory = getProviderFactoryOrComponentFactory(session, storageConfigScope);
|
||||
final MapStorageProvider factory = storageProviderFactory.create(session);
|
||||
session.enlistForClose(factory);
|
||||
return factory.getStorage(modelType);
|
||||
}
|
||||
|
||||
|
|
|
@ -127,6 +127,11 @@ public class DefaultKeycloakSession implements KeycloakSession {
|
|||
|
||||
@Override
|
||||
public void enlistForClose(Provider provider) {
|
||||
for (Provider p : closable) {
|
||||
if (p == provider) { // Do not add the same provider twice
|
||||
return;
|
||||
}
|
||||
}
|
||||
closable.add(provider);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue