Merge "Also check suppressed exceptions when detecting RequestCancelledException"
diff --git a/java/com/google/gerrit/server/cancellation/RequestCancelledException.java b/java/com/google/gerrit/server/cancellation/RequestCancelledException.java
index dc01567..9663427 100644
--- a/java/com/google/gerrit/server/cancellation/RequestCancelledException.java
+++ b/java/com/google/gerrit/server/cancellation/RequestCancelledException.java
@@ -15,7 +15,9 @@
package com.google.gerrit.server.cancellation;
import com.google.common.base.Throwables;
+import com.google.common.collect.Streams;
import com.google.gerrit.common.Nullable;
+import java.util.Arrays;
import java.util.Optional;
import org.apache.commons.text.WordUtils;
@@ -28,7 +30,9 @@
* {@link RequestCancelledException} is returned. If not, {@link Optional#empty()} is returned.
*/
public static Optional<RequestCancelledException> getFromCausalChain(Throwable e) {
- return Throwables.getCausalChain(e).stream()
+ return Streams.concat(
+ Throwables.getCausalChain(e).stream(),
+ Throwables.getCausalChain(e).stream().flatMap(t -> Arrays.stream(t.getSuppressed())))
.filter(RequestCancelledException.class::isInstance)
.map(RequestCancelledException.class::cast)
.findFirst();