AccountsUpdate: Remove upsert method
AccountManager#create was the only user of this method. This method
creates a new account. Since it creates the account with a new ID from
the account sequence it is unexpected that the insertion fails because
another account with the same ID already exists. However if this happens
we would rather like to fail than to overwrite that other account.
Since the upsert method is now unused it can be removed.
Change-Id: I79ce5d1146553723807a8bec4799da6d227bc321
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountManager.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountManager.java
index 861667b..16314a6 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountManager.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountManager.java
@@ -222,7 +222,7 @@
try {
AccountsUpdate accountsUpdate = accountsUpdateFactory.create();
- accountsUpdate.upsert(db, account);
+ accountsUpdate.insert(db, account);
ExternalId existingExtId = externalIds.get(extId.key());
if (existingExtId != null && !existingExtId.accountId().equals(extId.accountId())) {
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountsUpdate.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountsUpdate.java
index f6ed598..2860ae7 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountsUpdate.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountsUpdate.java
@@ -183,17 +183,6 @@
evictAccount(account.getId());
}
- /**
- * Inserts or updates an account.
- *
- * <p>If the account already exists, it is overwritten, otherwise it is inserted.
- */
- public void upsert(ReviewDb db, Account account) throws OrmException, IOException {
- db.accounts().upsert(ImmutableSet.of(account));
- createUserBranchIfNeeded(account);
- evictAccount(account.getId());
- }
-
/** Updates the account. */
public void update(ReviewDb db, Account account) throws OrmException, IOException {
db.accounts().update(ImmutableSet.of(account));
@@ -252,16 +241,6 @@
}
}
- private void createUserBranchIfNeeded(Account account) throws IOException {
- try (Repository repo = repoManager.openRepository(allUsersName);
- ObjectInserter oi = repo.newObjectInserter()) {
- if (repo.exactRef(RefNames.refsUsers(account.getId())) == null) {
- createUserBranch(
- repo, oi, committerIdent, authorIdent, account.getId(), account.getRegisteredOn());
- }
- }
- }
-
public static void createUserBranch(
Repository repo,
ObjectInserter oi,