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
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/ChangeUtil.java b/gerrit-server/src/main/java/com/google/gerrit/server/ChangeUtil.java
index 5d39fd3..87d0cff 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/ChangeUtil.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/ChangeUtil.java
@@ -20,6 +20,7 @@
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 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");
}
@@ -565,4 +565,4 @@
dst.setCharAt(o--, '0');
}
}
-}
+}
\ No newline at end of file
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/EditMessage.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/EditMessage.java
index c04c777..3942898 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/change/EditMessage.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/EditMessage.java
@@ -28,7 +28,6 @@
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 @@
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());
}
}