Remove declarations of unthrown IOException
Change-Id: I2697644c1364bc993ca526714e606d8cb24364f7
This commit is contained in:
@@ -27,7 +27,6 @@ import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.entities.Account;
|
||||
import com.google.gerrit.entities.PatchSet;
|
||||
import com.google.gerrit.entities.PatchSetApproval;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.ChangeKind;
|
||||
import com.google.gerrit.server.change.ChangeKindCache;
|
||||
import com.google.gerrit.server.change.LabelNormalizer;
|
||||
@@ -39,7 +38,6 @@ import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
@@ -91,8 +89,6 @@ public class ApprovalInference {
|
||||
Collection<PatchSetApproval> approvals =
|
||||
getForPatchSetWithoutNormalization(notes, project, psId, rw, repoConfig);
|
||||
return labelNormalizer.normalize(notes, approvals).getNormalized();
|
||||
} catch (IOException e) {
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -131,8 +131,7 @@ public class PatchSetUtil {
|
||||
}
|
||||
|
||||
/** Check if the current patch set of the change is locked. */
|
||||
public void checkPatchSetNotLocked(ChangeNotes notes)
|
||||
throws IOException, ResourceConflictException {
|
||||
public void checkPatchSetNotLocked(ChangeNotes notes) throws ResourceConflictException {
|
||||
if (isPatchSetLocked(notes)) {
|
||||
throw new ResourceConflictException(
|
||||
String.format("The current patch set of change %s is locked", notes.getChangeId()));
|
||||
@@ -140,7 +139,7 @@ public class PatchSetUtil {
|
||||
}
|
||||
|
||||
/** Is the current patch set locked against state changes? */
|
||||
public boolean isPatchSetLocked(ChangeNotes notes) throws IOException {
|
||||
public boolean isPatchSetLocked(ChangeNotes notes) {
|
||||
Change change = notes.getChange();
|
||||
if (change.isMerged()) {
|
||||
return false;
|
||||
|
@@ -31,7 +31,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -82,8 +81,7 @@ public class LabelNormalizer {
|
||||
* @return copies of approvals normalized to the defined ranges for the label type. Approvals for
|
||||
* unknown labels are not included in the output.
|
||||
*/
|
||||
public Result normalize(ChangeNotes notes, Collection<PatchSetApproval> approvals)
|
||||
throws IOException {
|
||||
public Result normalize(ChangeNotes notes, Collection<PatchSetApproval> approvals) {
|
||||
List<PatchSetApproval> unchanged = Lists.newArrayListWithCapacity(approvals.size());
|
||||
List<PatchSetApproval> updated = Lists.newArrayListWithCapacity(approvals.size());
|
||||
List<PatchSetApproval> deleted = Lists.newArrayListWithCapacity(approvals.size());
|
||||
|
@@ -238,7 +238,7 @@ public class RevisionJson {
|
||||
}
|
||||
|
||||
private Map<String, FetchInfo> makeFetchMap(ChangeData cd, PatchSet in)
|
||||
throws PermissionBackendException, IOException {
|
||||
throws PermissionBackendException {
|
||||
Map<String, FetchInfo> r = new LinkedHashMap<>();
|
||||
for (Extension<DownloadScheme> e : downloadSchemes) {
|
||||
String schemeName = e.getExportName();
|
||||
@@ -358,7 +358,7 @@ public class RevisionJson {
|
||||
: withUser.indexedChange(cd, notesFactory.createFromIndexedChange(cd.change()));
|
||||
}
|
||||
|
||||
private boolean isWorldReadable(ChangeData cd) throws PermissionBackendException, IOException {
|
||||
private boolean isWorldReadable(ChangeData cd) throws PermissionBackendException {
|
||||
try {
|
||||
permissionBackendForChange(permissionBackend.user(anonymous), cd)
|
||||
.check(ChangePermission.READ);
|
||||
|
@@ -413,7 +413,7 @@ public class ChangeEditModifier {
|
||||
}
|
||||
|
||||
private void assertCanEdit(ChangeNotes notes)
|
||||
throws AuthException, PermissionBackendException, IOException, ResourceConflictException {
|
||||
throws AuthException, PermissionBackendException, ResourceConflictException {
|
||||
if (!currentUser.get().isIdentifiedUser()) {
|
||||
throw new AuthException("Authentication required");
|
||||
}
|
||||
|
@@ -540,7 +540,7 @@ public class ReplaceOp implements BatchUpdateOp {
|
||||
}
|
||||
}
|
||||
|
||||
private void fireApprovalsEvent(Context ctx) throws IOException {
|
||||
private void fireApprovalsEvent(Context ctx) {
|
||||
if (approvals.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@@ -142,8 +142,7 @@ public class CommitValidators {
|
||||
NoteMap rejectCommits,
|
||||
RevWalk rw,
|
||||
@Nullable Change change,
|
||||
boolean skipValidation)
|
||||
throws IOException {
|
||||
boolean skipValidation) {
|
||||
PermissionBackend.ForRef perm = forProject.ref(branch.branch());
|
||||
ProjectState projectState =
|
||||
projectCache.get(branch.project()).orElseThrow(illegalState(branch.project()));
|
||||
@@ -172,8 +171,7 @@ public class CommitValidators {
|
||||
IdentifiedUser user,
|
||||
SshInfo sshInfo,
|
||||
RevWalk rw,
|
||||
@Nullable Change change)
|
||||
throws IOException {
|
||||
@Nullable Change change) {
|
||||
PermissionBackend.ForRef perm = forProject.ref(branch.branch());
|
||||
ProjectState projectState =
|
||||
projectCache.get(branch.project()).orElseThrow(illegalState(branch.project()));
|
||||
@@ -195,8 +193,7 @@ public class CommitValidators {
|
||||
}
|
||||
|
||||
public CommitValidators forMergedCommits(
|
||||
PermissionBackend.ForProject forProject, BranchNameKey branch, IdentifiedUser user)
|
||||
throws IOException {
|
||||
PermissionBackend.ForProject forProject, BranchNameKey branch, IdentifiedUser user) {
|
||||
// Generally only include validators that are based on permissions of the
|
||||
// user creating a change for a merged commit; generally exclude
|
||||
// validators that would require amending the change in order to correct.
|
||||
|
@@ -145,7 +145,7 @@ public class Abandon
|
||||
if (patchSetUtil.isPatchSetLocked(rsrc.getNotes())) {
|
||||
return description;
|
||||
}
|
||||
} catch (StorageException | IOException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Failed to check if the current patch set of change %s is locked", change.getId());
|
||||
return description;
|
||||
|
@@ -98,8 +98,7 @@ public class ChangesCollection implements RestCollection<TopLevelResource, Chang
|
||||
}
|
||||
|
||||
public ChangeResource parse(Change.Id id)
|
||||
throws ResourceConflictException, ResourceNotFoundException, PermissionBackendException,
|
||||
IOException {
|
||||
throws ResourceConflictException, ResourceNotFoundException, PermissionBackendException {
|
||||
List<ChangeNotes> notes = changeFinder.find(id);
|
||||
if (notes.isEmpty()) {
|
||||
throw new ResourceNotFoundException(toIdString(id));
|
||||
@@ -123,7 +122,7 @@ public class ChangesCollection implements RestCollection<TopLevelResource, Chang
|
||||
return changeResourceFactory.create(notes, user);
|
||||
}
|
||||
|
||||
private boolean canRead(ChangeNotes notes) throws PermissionBackendException, IOException {
|
||||
private boolean canRead(ChangeNotes notes) throws PermissionBackendException {
|
||||
try {
|
||||
permissionBackend.currentUser().change(notes).check(ChangePermission.READ);
|
||||
} catch (AuthException e) {
|
||||
|
@@ -311,7 +311,7 @@ public class Move implements RestModifyView<ChangeResource, MoveInput>, UiAction
|
||||
if (psUtil.isPatchSetLocked(rsrc.getNotes())) {
|
||||
return description;
|
||||
}
|
||||
} catch (StorageException | IOException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Failed to check if the current patch set of change %s is locked", change.getId());
|
||||
return description;
|
||||
|
@@ -179,7 +179,7 @@ public class PutMessage implements RestModifyView<ChangeResource, CommitMessageI
|
||||
}
|
||||
|
||||
private void ensureCanEditCommitMessage(ChangeNotes changeNotes)
|
||||
throws AuthException, PermissionBackendException, IOException, ResourceConflictException {
|
||||
throws AuthException, PermissionBackendException, ResourceConflictException {
|
||||
if (!userProvider.get().isIdentifiedUser()) {
|
||||
throw new AuthException("Authentication required");
|
||||
}
|
||||
|
@@ -238,7 +238,7 @@ public class Rebase
|
||||
if (patchSetUtil.isPatchSetLocked(rsrc.getNotes())) {
|
||||
return description;
|
||||
}
|
||||
} catch (StorageException | IOException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Failed to check if the current patch set of change %s is locked", change.getId());
|
||||
return description;
|
||||
|
@@ -146,7 +146,7 @@ class RelatedChangesSorter {
|
||||
|
||||
private Collection<PatchSetData> walkAncestors(
|
||||
ListMultimap<PatchSetData, PatchSetData> parents, PatchSetData start)
|
||||
throws PermissionBackendException, IOException {
|
||||
throws PermissionBackendException {
|
||||
LinkedHashSet<PatchSetData> result = new LinkedHashSet<>();
|
||||
Deque<PatchSetData> pending = new ArrayDeque<>();
|
||||
pending.add(start);
|
||||
@@ -166,7 +166,7 @@ class RelatedChangesSorter {
|
||||
PatchSetData start,
|
||||
List<PatchSetData> otherPatchSetsOfStart,
|
||||
Iterable<PatchSetData> ancestors)
|
||||
throws PermissionBackendException, IOException {
|
||||
throws PermissionBackendException {
|
||||
Set<Change.Id> alreadyEmittedChanges = new HashSet<>();
|
||||
addAllChangeIds(alreadyEmittedChanges, ancestors);
|
||||
|
||||
@@ -193,7 +193,7 @@ class RelatedChangesSorter {
|
||||
Set<Change.Id> alreadyEmittedChanges,
|
||||
ListMultimap<PatchSetData, PatchSetData> children,
|
||||
List<PatchSetData> start)
|
||||
throws PermissionBackendException, IOException {
|
||||
throws PermissionBackendException {
|
||||
if (start.isEmpty()) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
@@ -185,7 +185,7 @@ public class Restore
|
||||
if (psUtil.isPatchSetLocked(rsrc.getNotes())) {
|
||||
return description;
|
||||
}
|
||||
} catch (StorageException | IOException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Failed to check if the current patch set of change %s is locked", change.getId());
|
||||
return description;
|
||||
|
@@ -106,7 +106,7 @@ public class Revisions implements ChildCollection<ChangeResource, RevisionResour
|
||||
}
|
||||
}
|
||||
|
||||
private boolean visible(ChangeResource change) throws PermissionBackendException, IOException {
|
||||
private boolean visible(ChangeResource change) throws PermissionBackendException {
|
||||
try {
|
||||
permissionBackend
|
||||
.user(change.getUser())
|
||||
|
@@ -136,7 +136,7 @@ public class ProjectsCollection
|
||||
|
||||
@Nullable
|
||||
private ProjectResource _parse(String id, boolean checkAccess)
|
||||
throws IOException, PermissionBackendException, ResourceConflictException {
|
||||
throws PermissionBackendException, ResourceConflictException {
|
||||
id = ProjectUtil.sanitizeProjectName(id);
|
||||
|
||||
Project.NameKey nameKey = Project.nameKey(id);
|
||||
|
@@ -149,7 +149,7 @@ public class MergeSuperSet {
|
||||
*/
|
||||
private ChangeSet topicClosure(
|
||||
ChangeSet changeSet, CurrentUser user, Set<String> topicsSeen, Set<String> visibleTopicsSeen)
|
||||
throws PermissionBackendException, IOException {
|
||||
throws PermissionBackendException {
|
||||
List<ChangeData> visibleChanges = new ArrayList<>();
|
||||
List<ChangeData> nonVisibleChanges = new ArrayList<>();
|
||||
|
||||
|
@@ -30,7 +30,6 @@ import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.restapi.change.ChangesCollection;
|
||||
import com.google.gerrit.sshd.BaseCommand.UnloggedFailure;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -55,13 +54,13 @@ public class ChangeArgumentParser {
|
||||
}
|
||||
|
||||
public void addChange(String id, Map<Change.Id, ChangeResource> changes)
|
||||
throws UnloggedFailure, PermissionBackendException, IOException {
|
||||
throws UnloggedFailure, PermissionBackendException {
|
||||
addChange(id, changes, null);
|
||||
}
|
||||
|
||||
public void addChange(
|
||||
String id, Map<Change.Id, ChangeResource> changes, @Nullable ProjectState projectState)
|
||||
throws UnloggedFailure, PermissionBackendException, IOException {
|
||||
throws UnloggedFailure, PermissionBackendException {
|
||||
addChange(id, changes, projectState, true);
|
||||
}
|
||||
|
||||
@@ -70,7 +69,7 @@ public class ChangeArgumentParser {
|
||||
Map<Change.Id, ChangeResource> changes,
|
||||
@Nullable ProjectState projectState,
|
||||
boolean useIndex)
|
||||
throws UnloggedFailure, PermissionBackendException, IOException {
|
||||
throws UnloggedFailure, PermissionBackendException {
|
||||
List<ChangeNotes> matched = useIndex ? changeFinder.find(id) : changeFromNotesFactory(id);
|
||||
List<ChangeNotes> toAdd = new ArrayList<>(changes.size());
|
||||
boolean canMaintainServer;
|
||||
|
@@ -24,7 +24,6 @@ import com.google.gerrit.sshd.ChangeArgumentParser;
|
||||
import com.google.gerrit.sshd.CommandMetaData;
|
||||
import com.google.gerrit.sshd.SshCommand;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import org.kohsuke.args4j.Argument;
|
||||
@@ -44,7 +43,7 @@ final class IndexChangesCommand extends SshCommand {
|
||||
void addChange(String token) {
|
||||
try {
|
||||
changeArgumentParser.addChange(token, changes, null, false);
|
||||
} catch (UnloggedFailure | StorageException | PermissionBackendException | IOException e) {
|
||||
} catch (UnloggedFailure | StorageException | PermissionBackendException e) {
|
||||
writeError("warning", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,6 @@ import com.google.gerrit.sshd.ChangeArgumentParser;
|
||||
import com.google.gerrit.sshd.CommandMetaData;
|
||||
import com.google.gerrit.sshd.SshCommand;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -73,7 +72,7 @@ public class SetReviewersCommand extends SshCommand {
|
||||
void addChange(String token) {
|
||||
try {
|
||||
changeArgumentParser.addChange(token, changes, projectState);
|
||||
} catch (IOException | UnloggedFailure e) {
|
||||
} catch (UnloggedFailure e) {
|
||||
throw new IllegalArgumentException(e.getMessage(), e);
|
||||
} catch (StorageException e) {
|
||||
throw new IllegalArgumentException("database is down", e);
|
||||
|
@@ -259,8 +259,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
boolean exclusive,
|
||||
String labelName,
|
||||
int min,
|
||||
int max)
|
||||
throws IOException {
|
||||
int max) {
|
||||
ProjectConfig cfg = projectCache.get(project).orElseThrow(illegalState(project)).getConfig();
|
||||
AccessSection accessSection = cfg.getAccessSection(ref);
|
||||
assertThat(accessSection).isNotNull();
|
||||
|
Reference in New Issue
Block a user