Merge "ExceptionHookImpl: Identify exceptions cause by MissingObjectException"
diff --git a/java/com/google/gerrit/server/ExceptionHookImpl.java b/java/com/google/gerrit/server/ExceptionHookImpl.java
index 8393451..5a3f077 100644
--- a/java/com/google/gerrit/server/ExceptionHookImpl.java
+++ b/java/com/google/gerrit/server/ExceptionHookImpl.java
@@ -20,6 +20,7 @@
import com.google.gerrit.common.Nullable;
import com.google.gerrit.git.LockFailureException;
import java.util.Optional;
+import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.RefUpdate;
/**
@@ -42,6 +43,9 @@
if (isLockFailure(throwable)) {
return Optional.of(RefUpdate.Result.LOCK_FAILURE.name());
}
+ if (isMissingObjectException(throwable)) {
+ return Optional.of("missing_object");
+ }
return Optional.empty();
}
@@ -65,6 +69,10 @@
return isMatching(throwable, t -> t instanceof LockFailureException);
}
+ private static boolean isMissingObjectException(Throwable throwable) {
+ return isMatching(throwable, t -> t instanceof MissingObjectException);
+ }
+
/**
* Check whether the given exception or any of its causes matches the given predicate.
*