From 24715eabec397488f57781254543599baa258b1e Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Wed, 19 Oct 2016 09:06:55 +0200 Subject: [PATCH] KEYCLOAK-3737 Migration problem from version 1.9.8 to 2.2.1 --- .../java/org/keycloak/migration/migrators/MigrationUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server-spi/src/main/java/org/keycloak/migration/migrators/MigrationUtils.java b/server-spi/src/main/java/org/keycloak/migration/migrators/MigrationUtils.java index e9d0cb911d..ae3a99fa4c 100644 --- a/server-spi/src/main/java/org/keycloak/migration/migrators/MigrationUtils.java +++ b/server-spi/src/main/java/org/keycloak/migration/migrators/MigrationUtils.java @@ -33,7 +33,7 @@ public class MigrationUtils { public static void addAdminRole(RealmModel realm, String roleName) { ClientModel client = realm.getMasterAdminClient(); - if (client.getRole(roleName) == null) { + if (client != null && client.getRole(roleName) == null) { RoleModel role = client.addRole(roleName); role.setDescription("${role_" + roleName + "}"); role.setScopeParamRequired(false); @@ -43,7 +43,7 @@ public class MigrationUtils { if (!realm.getName().equals(Config.getAdminRealm())) { client = realm.getClientByClientId(Constants.REALM_MANAGEMENT_CLIENT_ID); - if (client.getRole(roleName) == null) { + if (client != null && client.getRole(roleName) == null) { RoleModel role = client.addRole(roleName); role.setDescription("${role_" + roleName + "}"); role.setScopeParamRequired(false);