SingleUserGroup: Use AccountCache#getOrNull instead of AccountCache#get If an account doesn't exist AccountCache#get returns an empty AccountState instance to represent the missing account. We don't need single user groups for missing accounts, hence use AccountCache#getOrNull instead. Change-Id: Ie6b1073979bc26c8f960fb01cf63ade79d60f4d4 Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroup.java b/src/main/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroup.java index c2869b2..327849d 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroup.java +++ b/src/main/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroup.java
@@ -106,7 +106,7 @@ String ident = username(uuid); Optional<AccountState> state; if (ident.matches(ACCOUNT_ID_PATTERN)) { - state = Optional.of(accountCache.get(new Account.Id(Integer.parseInt(ident)))); + state = Optional.ofNullable(accountCache.getOrNull(new Account.Id(Integer.parseInt(ident)))); } else if (ident.matches(Account.USER_NAME_PATTERN)) { state = accountCache.getByUsername(ident); } else {