Make AccountState an AutoValue

AccountState is a cached entity that is shared between different
threads. We therefore want it to be immutable. AutoValue is the
preferred way of generating immutable entities that have equals and
toString implementations and is used for almost all other caches. Hence,
we use it for AccountState too.

Change-Id: I3b19ef34791c8800667fdcf9ad8beade8539af13
This commit is contained in:
Patrick Hiesel
2019-08-07 15:25:07 +02:00
parent a5dd85e5d2
commit 3e64fd492b
82 changed files with 253 additions and 278 deletions

View File

@@ -152,7 +152,7 @@ class ProjectOAuthFilter implements Filter {
}
Optional<AccountState> who =
accountCache.getByUsername(authInfo.username).filter(a -> a.getAccount().isActive());
accountCache.getByUsername(authInfo.username).filter(a -> a.account().isActive());
if (!who.isPresent()) {
logger.atWarning().log(
authenticationFailedMsg(authInfo.username, req)
@@ -161,7 +161,7 @@ class ProjectOAuthFilter implements Filter {
return false;
}
Account account = who.get().getAccount();
Account account = who.get().account();
AuthRequest authRequest = AuthRequest.forExternalUser(authInfo.username);
authRequest.setEmailAddress(account.preferredEmail());
authRequest.setDisplayName(account.fullName());