diff --git a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/ClientAdapter.java b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/ClientAdapter.java index 11c1c62ac7..6f7608577b 100755 --- a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/ClientAdapter.java +++ b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/ClientAdapter.java @@ -569,10 +569,7 @@ public class ClientAdapter implements ClientModel { @Override public RoleModel getRole(String name) { - for (RoleModel role : getRoles()) { - if (role.getName().equals(name)) return role; - } - return null; + return cacheSession.getClientRole(getRealm(), this, name); } @Override diff --git a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmAdapter.java b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmAdapter.java index 0b36d671d3..1e6109f6b1 100755 --- a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmAdapter.java +++ b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmAdapter.java @@ -801,10 +801,7 @@ public class RealmAdapter implements CachedRealmModel { @Override public RoleModel getRole(String name) { - for (RoleModel role : getRoles()) { - if (role.getName().equals(name)) return role; - } - return null; + return cacheSession.getRealmRole(this, name); } @Override