Merge "ExceptionHookImpl: Identify exceptions cause by MissingObjectException"

This commit is contained in:
David Pursehouse
2020-01-20 07:40:32 +00:00
committed by Gerrit Code Review

View File

@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList;
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 @@ public class ExceptionHookImpl implements ExceptionHook {
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 @@ public class ExceptionHookImpl implements ExceptionHook {
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.
*