[KEYCLOAK-8789] Fix getAttribute(String name) implementations so they never return null

- user adapter classes were violating the UserModel contract as the javadoc for the method states that null must never be returned
This commit is contained in:
Stefan Guilhen 2020-03-31 12:22:05 -03:00 committed by Hynek Mlnařík
parent 845195780e
commit d3a4bef9a4
2 changed files with 3 additions and 2 deletions

View file

@ -323,7 +323,7 @@ public abstract class AbstractUserAdapter implements UserModel {
@Override @Override
public List<String> getAttribute(String name) { public List<String> getAttribute(String name) {
return null; return Collections.emptyList();
} }
@Override @Override

View file

@ -364,7 +364,8 @@ public abstract class AbstractUserAdapterFederatedStorage implements UserModel {
@Override @Override
public List<String> getAttribute(String name) { public List<String> getAttribute(String name) {
return getFederatedStorage().getAttributes(realm, this.getId()).get(name); List<String> result = getFederatedStorage().getAttributes(realm, this.getId()).get(name);
return (result == null) ? Collections.emptyList() : result;
} }
@Override @Override