ChangeUtil: Perform some code clean ups
Remove exception declarations that aren't thrown and use utility method to check for string emptiness. Change-Id: Icbe4228624366b6d4d95c59d0d45f9820dd412a2
This commit is contained in:
@@ -20,6 +20,7 @@ import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
@@ -375,14 +376,13 @@ public class ChangeUtil {
|
||||
}
|
||||
|
||||
public Change.Id editCommitMessage(ChangeControl ctl, PatchSet ps,
|
||||
String message, PersonIdent myIdent)
|
||||
throws NoSuchChangeException, EmailException, OrmException,
|
||||
MissingObjectException, IncorrectObjectTypeException, IOException,
|
||||
InvalidChangeOperationException, PatchSetInfoNotAvailableException {
|
||||
String message, PersonIdent myIdent) throws NoSuchChangeException,
|
||||
OrmException, MissingObjectException, IncorrectObjectTypeException,
|
||||
IOException, InvalidChangeOperationException {
|
||||
Change change = ctl.getChange();
|
||||
Change.Id changeId = change.getId();
|
||||
|
||||
if (message == null || message.length() == 0) {
|
||||
if (Strings.isNullOrEmpty(message)) {
|
||||
throw new InvalidChangeOperationException(
|
||||
"The commit message cannot be empty");
|
||||
}
|
||||
|
@@ -28,7 +28,6 @@ import com.google.gerrit.server.ChangeUtil;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
import com.google.gerrit.server.change.ChangeJson.ChangeInfo;
|
||||
import com.google.gerrit.server.change.EditMessage.Input;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
||||
import com.google.gerrit.server.project.InvalidChangeOperationException;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
@@ -84,8 +83,7 @@ class EditMessage implements RestModifyView<RevisionResource, Input>,
|
||||
throw new BadRequestException(e.getMessage());
|
||||
} catch (NoSuchChangeException e) {
|
||||
throw new ResourceNotFoundException();
|
||||
} catch (MissingObjectException | IncorrectObjectTypeException
|
||||
| PatchSetInfoNotAvailableException e) {
|
||||
} catch (MissingObjectException | IncorrectObjectTypeException e) {
|
||||
throw new ResourceConflictException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user