Merge changes I552aa95c,Ie65aeb40,I7cf2b92f
* changes: Add Javadoc and use a more general name for SchemaUpgradeTestEnvironment Use retry mechanism for group creations and name updates RetryHelper: Let callers care about exception handling
This commit is contained in:
@@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.Runnables;
|
||||
@@ -37,6 +38,7 @@ import com.google.gerrit.server.git.MetaDataUpdate;
|
||||
import com.google.gerrit.server.index.change.ReindexAfterRefUpdate;
|
||||
import com.google.gerrit.server.update.RefUpdateUtil;
|
||||
import com.google.gerrit.server.update.RetryHelper;
|
||||
import com.google.gerrit.server.update.RetryHelper.Action;
|
||||
import com.google.gerrit.server.update.RetryHelper.ActionType;
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
@@ -498,8 +500,7 @@ public class AccountsUpdate {
|
||||
|
||||
private Optional<AccountState> updateAccount(AccountUpdate accountUpdate)
|
||||
throws IOException, ConfigInvalidException, OrmException {
|
||||
return retryHelper.execute(
|
||||
ActionType.ACCOUNT_UPDATE,
|
||||
return executeAccountUpdate(
|
||||
() -> {
|
||||
try (Repository allUsersRepo = repoManager.openRepository(allUsersName)) {
|
||||
UpdatedAccount updatedAccount = accountUpdate.update(allUsersRepo);
|
||||
@@ -513,6 +514,20 @@ public class AccountsUpdate {
|
||||
});
|
||||
}
|
||||
|
||||
private Optional<AccountState> executeAccountUpdate(Action<Optional<AccountState>> action)
|
||||
throws IOException, ConfigInvalidException, OrmException {
|
||||
try {
|
||||
return retryHelper.execute(
|
||||
ActionType.ACCOUNT_UPDATE, action, LockFailureException.class::isInstance);
|
||||
} catch (Exception e) {
|
||||
Throwables.throwIfUnchecked(e);
|
||||
Throwables.throwIfInstanceOf(e, IOException.class);
|
||||
Throwables.throwIfInstanceOf(e, ConfigInvalidException.class);
|
||||
Throwables.throwIfInstanceOf(e, OrmException.class);
|
||||
throw new OrmException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private ExternalIdNotes createExternalIdNotes(
|
||||
Repository allUsersRepo,
|
||||
Optional<ObjectId> rev,
|
||||
|
Reference in New Issue
Block a user