Remove StorageException from throws clauses
Change-Id: I48a0169293ddf766fbbd924cb310f9b8dacc58cf
This commit is contained in:
@@ -30,7 +30,6 @@ import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.common.data.PermissionRule;
|
||||
import com.google.gerrit.common.data.PermissionRule.Action;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
@@ -86,8 +85,7 @@ public class AllProjectsCreator {
|
||||
this.owners = systemGroupBackend.getGroup(PROJECT_OWNERS);
|
||||
}
|
||||
|
||||
public void create(AllProjectsInput input)
|
||||
throws IOException, ConfigInvalidException, StorageException {
|
||||
public void create(AllProjectsInput input) throws IOException, ConfigInvalidException {
|
||||
try (Repository git = repositoryManager.openRepository(allProjectsName)) {
|
||||
initAllProjects(git, input);
|
||||
} catch (RepositoryNotFoundException notFound) {
|
||||
@@ -105,7 +103,7 @@ public class AllProjectsCreator {
|
||||
}
|
||||
|
||||
private void initAllProjects(Repository git, AllProjectsInput input)
|
||||
throws IOException, ConfigInvalidException, StorageException {
|
||||
throws ConfigInvalidException, IOException {
|
||||
BatchRefUpdate bru = git.getRefDatabase().newBatchUpdate();
|
||||
try (MetaDataUpdate md =
|
||||
new MetaDataUpdate(GitReferenceUpdated.DISABLED, allProjectsName, git, bru)) {
|
||||
|
||||
@@ -176,7 +176,7 @@ public abstract class JdbcAccountPatchReviewStore
|
||||
return ds.getConnection();
|
||||
}
|
||||
|
||||
public void createTableIfNotExists() throws StorageException {
|
||||
public void createTableIfNotExists() {
|
||||
try (Connection con = ds.getConnection();
|
||||
Statement stmt = con.createStatement()) {
|
||||
doCreateTable(stmt);
|
||||
@@ -197,7 +197,7 @@ public abstract class JdbcAccountPatchReviewStore
|
||||
+ ")");
|
||||
}
|
||||
|
||||
public void dropTableIfExists() throws StorageException {
|
||||
public void dropTableIfExists() {
|
||||
try (Connection con = ds.getConnection();
|
||||
Statement stmt = con.createStatement()) {
|
||||
stmt.executeUpdate("DROP TABLE IF EXISTS account_patch_reviews");
|
||||
@@ -210,8 +210,7 @@ public abstract class JdbcAccountPatchReviewStore
|
||||
public void stop() {}
|
||||
|
||||
@Override
|
||||
public boolean markReviewed(PatchSet.Id psId, Account.Id accountId, String path)
|
||||
throws StorageException {
|
||||
public boolean markReviewed(PatchSet.Id psId, Account.Id accountId, String path) {
|
||||
try (Connection con = ds.getConnection();
|
||||
PreparedStatement stmt =
|
||||
con.prepareStatement(
|
||||
@@ -234,8 +233,7 @@ public abstract class JdbcAccountPatchReviewStore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markReviewed(PatchSet.Id psId, Account.Id accountId, Collection<String> paths)
|
||||
throws StorageException {
|
||||
public void markReviewed(PatchSet.Id psId, Account.Id accountId, Collection<String> paths) {
|
||||
if (paths == null || paths.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -264,8 +262,7 @@ public abstract class JdbcAccountPatchReviewStore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearReviewed(PatchSet.Id psId, Account.Id accountId, String path)
|
||||
throws StorageException {
|
||||
public void clearReviewed(PatchSet.Id psId, Account.Id accountId, String path) {
|
||||
try (Connection con = ds.getConnection();
|
||||
PreparedStatement stmt =
|
||||
con.prepareStatement(
|
||||
@@ -283,7 +280,7 @@ public abstract class JdbcAccountPatchReviewStore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearReviewed(PatchSet.Id psId) throws StorageException {
|
||||
public void clearReviewed(PatchSet.Id psId) {
|
||||
try (Connection con = ds.getConnection();
|
||||
PreparedStatement stmt =
|
||||
con.prepareStatement(
|
||||
@@ -298,8 +295,7 @@ public abstract class JdbcAccountPatchReviewStore
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<PatchSetWithReviewedFiles> findReviewed(PatchSet.Id psId, Account.Id accountId)
|
||||
throws StorageException {
|
||||
public Optional<PatchSetWithReviewedFiles> findReviewed(PatchSet.Id psId, Account.Id accountId) {
|
||||
try (Connection con = ds.getConnection();
|
||||
PreparedStatement stmt =
|
||||
con.prepareStatement(
|
||||
|
||||
@@ -77,7 +77,7 @@ public class NoteDbSchemaUpdater {
|
||||
this.schemaVersions = schemaVersions;
|
||||
}
|
||||
|
||||
public void update(UpdateUI ui) throws StorageException {
|
||||
public void update(UpdateUI ui) {
|
||||
ensureSchemaCreated();
|
||||
|
||||
int currentVersion = versionManager.read();
|
||||
@@ -100,7 +100,7 @@ public class NoteDbSchemaUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureSchemaCreated() throws StorageException {
|
||||
private void ensureSchemaCreated() {
|
||||
try {
|
||||
schemaCreator.ensureCreated();
|
||||
} catch (IOException | ConfigInvalidException e) {
|
||||
@@ -114,7 +114,7 @@ public class NoteDbSchemaUpdater {
|
||||
NOTE_DB
|
||||
}
|
||||
|
||||
private void checkNoteDbConfigFor216() throws StorageException {
|
||||
private void checkNoteDbConfigFor216() {
|
||||
// Check that the NoteDb migration config matches what we expect from a site that both:
|
||||
// * Completed the change migration to NoteDB.
|
||||
// * Ran schema upgrades from a 2.16 final release.
|
||||
@@ -160,7 +160,7 @@ public class NoteDbSchemaUpdater {
|
||||
|
||||
@VisibleForTesting
|
||||
static ImmutableList<Integer> requiredUpgrades(
|
||||
int currentVersion, ImmutableSortedSet<Integer> allVersions) throws StorageException {
|
||||
int currentVersion, ImmutableSortedSet<Integer> allVersions) {
|
||||
int firstVersion = allVersions.first();
|
||||
int latestVersion = allVersions.last();
|
||||
if (currentVersion == latestVersion) {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class NoteDbSchemaVersionManager {
|
||||
this.repoManager = repoManager;
|
||||
}
|
||||
|
||||
public int read() throws StorageException {
|
||||
public int read() {
|
||||
try (Repository repo = repoManager.openRepository(allProjectsName)) {
|
||||
return IntBlob.parse(repo, REFS_VERSION).map(IntBlob::value).orElse(0);
|
||||
} catch (IOException e) {
|
||||
@@ -53,7 +53,7 @@ public class NoteDbSchemaVersionManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void init() throws IOException, StorageException {
|
||||
public void init() throws IOException {
|
||||
try (Repository repo = repoManager.openRepository(allProjectsName);
|
||||
RevWalk rw = new RevWalk(repo)) {
|
||||
Optional<IntBlob> old = IntBlob.parse(repo, REFS_VERSION, rw);
|
||||
@@ -73,7 +73,7 @@ public class NoteDbSchemaVersionManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void increment(int expectedOldVersion) throws IOException, StorageException {
|
||||
public void increment(int expectedOldVersion) throws IOException {
|
||||
try (Repository repo = repoManager.openRepository(allProjectsName);
|
||||
RevWalk rw = new RevWalk(repo)) {
|
||||
Optional<IntBlob> old = IntBlob.parse(repo, REFS_VERSION, rw);
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ProjectConfigSchemaUpdate extends VersionedMetaData {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void save(PersonIdent personIdent, String commitMessage) throws StorageException {
|
||||
public void save(PersonIdent personIdent, String commitMessage) {
|
||||
if (!updated) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
package com.google.gerrit.server.schema;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import java.io.IOException;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
|
||||
@@ -26,20 +25,18 @@ public interface SchemaCreator {
|
||||
*
|
||||
* <p>Fails if the schema does exist.
|
||||
*
|
||||
* @throws StorageException an error occurred.
|
||||
* @throws IOException an error occurred.
|
||||
* @throws ConfigInvalidException an error occurred.
|
||||
*/
|
||||
void create() throws StorageException, IOException, ConfigInvalidException;
|
||||
void create() throws IOException, ConfigInvalidException;
|
||||
|
||||
/**
|
||||
* Create the schema only if it does not already exist.
|
||||
*
|
||||
* <p>Succeeds if the schema does exist.
|
||||
*
|
||||
* @throws StorageException an error occurred.
|
||||
* @throws IOException an error occurred.
|
||||
* @throws ConfigInvalidException an error occurred.
|
||||
*/
|
||||
void ensureCreated() throws StorageException, IOException, ConfigInvalidException;
|
||||
void ensureCreated() throws IOException, ConfigInvalidException;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.GroupReference;
|
||||
import com.google.gerrit.exceptions.DuplicateKeyException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.git.RefUpdateUtil;
|
||||
import com.google.gerrit.metrics.MetricMaker;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
@@ -90,7 +89,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() throws StorageException, IOException, ConfigInvalidException {
|
||||
public void create() throws IOException, ConfigInvalidException {
|
||||
GroupReference admins = createGroupReference("Administrators");
|
||||
GroupReference batchUsers = createGroupReference("Non-Interactive Users");
|
||||
|
||||
@@ -117,7 +116,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ensureCreated() throws StorageException, IOException, ConfigInvalidException {
|
||||
public void ensureCreated() throws IOException, ConfigInvalidException {
|
||||
try {
|
||||
repoManager.openRepository(allProjectsName).close();
|
||||
} catch (RepositoryNotFoundException e) {
|
||||
@@ -127,7 +126,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
|
||||
|
||||
private void createAdminsGroup(
|
||||
Sequences seqs, Repository allUsersRepo, GroupReference groupReference)
|
||||
throws StorageException, IOException, ConfigInvalidException {
|
||||
throws IOException, ConfigInvalidException {
|
||||
InternalGroupCreation groupCreation = getGroupCreation(seqs, groupReference);
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder().setDescription("Gerrit Site Administrators").build();
|
||||
@@ -140,7 +139,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
|
||||
Repository allUsersRepo,
|
||||
GroupReference groupReference,
|
||||
AccountGroup.UUID adminsGroupUuid)
|
||||
throws StorageException, IOException, ConfigInvalidException {
|
||||
throws IOException, ConfigInvalidException {
|
||||
InternalGroupCreation groupCreation = getGroupCreation(seqs, groupReference);
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder()
|
||||
@@ -153,7 +152,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
|
||||
|
||||
private void createGroup(
|
||||
Repository allUsersRepo, InternalGroupCreation groupCreation, InternalGroupUpdate groupUpdate)
|
||||
throws StorageException, ConfigInvalidException, IOException {
|
||||
throws ConfigInvalidException, IOException {
|
||||
InternalGroup createdGroup = createGroupInNoteDb(allUsersRepo, groupCreation, groupUpdate);
|
||||
index(createdGroup);
|
||||
}
|
||||
@@ -216,8 +215,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
|
||||
return new GroupReference(groupUuid, name);
|
||||
}
|
||||
|
||||
private InternalGroupCreation getGroupCreation(Sequences seqs, GroupReference groupReference)
|
||||
throws StorageException {
|
||||
private InternalGroupCreation getGroupCreation(Sequences seqs, GroupReference groupReference) {
|
||||
int next = seqs.nextGroupId();
|
||||
return InternalGroupCreation.builder()
|
||||
.setNameKey(new AccountGroup.NameKey(groupReference.getName()))
|
||||
|
||||
Reference in New Issue
Block a user