AccountsUpdate#update: Return Optional<AccountState> instead of AccountState

This makes it more explicit that callers must handle the case where the
returned AccountState is absent.

Change-Id: Id301678f97d2a8827c3a23d85cbc5f6da97abc7c
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-01-12 10:52:25 +01:00
parent 5c37073931
commit d40d81482d
8 changed files with 103 additions and 112 deletions

View File

@@ -2981,7 +2981,7 @@ class ReceiveCommits {
}
logDebug("Updating full name of caller");
try {
AccountState accountState =
Optional<AccountState> accountState =
accountsUpdate
.create()
.update(
@@ -2992,9 +2992,9 @@ class ReceiveCommits {
u.setFullName(setFullNameTo);
}
});
if (accountState != null) {
user.getAccount().setFullName(accountState.getAccount().getFullName());
}
accountState
.map(AccountState::getAccount)
.ifPresent(a -> user.getAccount().setFullName(a.getFullName()));
} catch (OrmException | IOException | ConfigInvalidException e) {
logWarn("Failed to update full name of caller", e);
}