Skip to content

Commit

Permalink
Ensure map storage providers are closed upon session close
Browse files Browse the repository at this point in the history
  • Loading branch information
hmlnarik authored and mhajas committed Oct 5, 2022
1 parent 425b6b8 commit 36a1ce6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public String getId() {
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ public void invalidate(InvalidableObjectType type, Object... ids) {

@Override
public void enlistForClose(Provider provider) {
for (Provider p : closable) {
if (p == provider) { // Do not add the same provider twice
return;
}
}
closable.add(provider);
}

Expand Down

0 comments on commit 36a1ce6

Please sign in to comment.