CherryPick: check for null with checkNotNull instead of checkState

Contrary to checkState, FindBugs recognises checkNotNull and will
not raise warnings about subsequent dereferences of objects that
could be null.

Change-Id: I1c4edbcad2e6a8bc295ebead9aedd93c2d79654b
This commit is contained in:
David Pursehouse
2016-02-12 18:20:40 +09:00
parent e68af5dfe9
commit 4e6ef29eab

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.git.strategy; package com.google.gerrit.server.git.strategy;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.gerrit.server.git.strategy.CommitMergeStatus.SKIPPED_IDENTICAL_TREE; import static com.google.gerrit.server.git.strategy.CommitMergeStatus.SKIPPED_IDENTICAL_TREE;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@@ -151,7 +151,7 @@ public class CherryPick extends SubmitStrategy {
&& toMerge.getStatusCode() == SKIPPED_IDENTICAL_TREE) { && toMerge.getStatusCode() == SKIPPED_IDENTICAL_TREE) {
return null; return null;
} }
checkState(newCommit != null, checkNotNull(newCommit,
"no new commit produced by CherryPick of %s, expected to fail fast", "no new commit produced by CherryPick of %s, expected to fail fast",
toMerge.change().getId()); toMerge.change().getId());
PatchSet prevPs = args.psUtil.current(ctx.getDb(), ctx.getNotes()); PatchSet prevPs = args.psUtil.current(ctx.getDb(), ctx.getNotes());