aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar olaola <olaola@google.com>2017-10-02 23:04:51 +0200
committerGravatar Klaus Aehlig <aehlig@google.com>2017-10-06 19:42:29 +0200
commitc43c0acdc23c8d197e9a47c347e2d05ea76242ed (patch)
tree8065b3f4983f3f48319a495fc2cacd76d7382675 /src/main/java/com/google/devtools/build
parent3003efdb798eb07f200fe87113945b19b1315a1b (diff)
Fixing displayed retry attempts one-off error, when the error is non-retriable.
Adding unit tests. TESTED=unit tests RELNOTES: None PiperOrigin-RevId: 170750220
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/Retrier.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/Retrier2.java8
2 files changed, 6 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/Retrier.java b/src/main/java/com/google/devtools/build/lib/remote/Retrier.java
index 8ce9d0aa07..197f2b5e77 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/Retrier.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/Retrier.java
@@ -207,13 +207,14 @@ public class Retrier {
throw e; // Nested retries are always pass-through.
} catch (StatusException | StatusRuntimeException e) {
Status st = Status.fromThrowable(e);
+ int attempts = backoff.getRetryAttempts();
long delay = backoff.nextDelayMillis();
if (st.getCode() == Status.Code.CANCELLED && Thread.currentThread().isInterrupted()) {
Thread.currentThread().interrupt();
throw new InterruptedException();
}
if (delay < 0 || !isRetriable.apply(st)) {
- throw new RetryException(st.asRuntimeException(), backoff.getRetryAttempts());
+ throw new RetryException(st.asRuntimeException(), attempts);
}
sleep(delay);
} catch (Exception e) {
diff --git a/src/main/java/com/google/devtools/build/lib/remote/Retrier2.java b/src/main/java/com/google/devtools/build/lib/remote/Retrier2.java
index 3f817d0fcc..e9a938b658 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/Retrier2.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/Retrier2.java
@@ -233,14 +233,14 @@ class Retrier2 {
throw new CircuitBreakerException("Call failed in circuit breaker half open state.", 0,
e);
}
+ int attempts = backoff.getRetryAttempts();
if (!shouldRetry.test(e)) {
- throw new RetryException2("Call failed with not retriable error.",
- backoff.getRetryAttempts(), e);
+ throw new RetryException2("Call failed with not retriable error.", attempts, e);
}
final long delayMillis = backoff.nextDelayMillis();
if (delayMillis < 0) {
- throw new RetryException2("Call failed after exhausting retry attempts: "
- + backoff.getRetryAttempts(), backoff.getRetryAttempts(), e);
+ throw new RetryException2(
+ "Call failed after exhausting retry attempts: " + attempts, attempts, e);
}
sleeper.sleep(delayMillis);
}