diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProviderFactory.java b/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProviderFactory.java index 1fdddd4e3b..7947b60877 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProviderFactory.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProviderFactory.java @@ -67,7 +67,9 @@ public class JpaRealmProviderFactory implements RealmProviderFactory, ProviderEv @Override public void close() { - onClose.run(); + if (onClose != null) { + onClose.run(); + } } @Override diff --git a/model/legacy-private/src/main/java/org/keycloak/storage/datastore/LegacyDatastoreProviderFactory.java b/model/legacy-private/src/main/java/org/keycloak/storage/datastore/LegacyDatastoreProviderFactory.java index 2f80ea1000..7e2ea943e7 100644 --- a/model/legacy-private/src/main/java/org/keycloak/storage/datastore/LegacyDatastoreProviderFactory.java +++ b/model/legacy-private/src/main/java/org/keycloak/storage/datastore/LegacyDatastoreProviderFactory.java @@ -66,7 +66,9 @@ public class LegacyDatastoreProviderFactory implements DatastoreProviderFactory, @Override public void close() { - onClose.run(); + if (onClose != null) { + onClose.run(); + } } @Override