Merge "ExceptionHookImpl: Identify exceptions cause by MissingObjectException"
This commit is contained in:
@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.git.LockFailureException;
|
import com.google.gerrit.git.LockFailureException;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.eclipse.jgit.errors.MissingObjectException;
|
||||||
import org.eclipse.jgit.lib.RefUpdate;
|
import org.eclipse.jgit.lib.RefUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +43,9 @@ public class ExceptionHookImpl implements ExceptionHook {
|
|||||||
if (isLockFailure(throwable)) {
|
if (isLockFailure(throwable)) {
|
||||||
return Optional.of(RefUpdate.Result.LOCK_FAILURE.name());
|
return Optional.of(RefUpdate.Result.LOCK_FAILURE.name());
|
||||||
}
|
}
|
||||||
|
if (isMissingObjectException(throwable)) {
|
||||||
|
return Optional.of("missing_object");
|
||||||
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +69,10 @@ public class ExceptionHookImpl implements ExceptionHook {
|
|||||||
return isMatching(throwable, t -> t instanceof LockFailureException);
|
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.
|
* Check whether the given exception or any of its causes matches the given predicate.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user