AccountsUpdate: Return AccountState instead of Account

On insert/update of an account the updated Account instance was
returned. However on insert/update of an account not only account
properties can be set, but also external IDs, watched projectis and
general preferences. To be consistent we should rather return the
updated AccountState which includes external IDs, watched projects and
general preferences in addition to the account.

Change-Id: Iff30984fe39551f88480399b57ce9cb3a90a10e2
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-01-10 13:28:50 +01:00
parent 06e676fc95
commit d845be694f
8 changed files with 77 additions and 53 deletions

View File

@@ -92,6 +92,7 @@ import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.PatchSetUtil;
import com.google.gerrit.server.Sequences;
import com.google.gerrit.server.account.AccountResolver;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.AccountsUpdate;
import com.google.gerrit.server.change.ChangeInserter;
import com.google.gerrit.server.change.SetHashtagsOp;
@@ -2980,7 +2981,7 @@ class ReceiveCommits {
}
logDebug("Updating full name of caller");
try {
Account account =
AccountState accountState =
accountsUpdate
.create()
.update(
@@ -2991,8 +2992,8 @@ class ReceiveCommits {
u.setFullName(setFullNameTo);
}
});
if (account != null) {
user.getAccount().setFullName(account.getFullName());
if (accountState != null) {
user.getAccount().setFullName(accountState.getAccount().getFullName());
}
} catch (OrmException | IOException | ConfigInvalidException e) {
logWarn("Failed to update full name of caller", e);