Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ public Publisher<Long> apply(Multi<Throwable> t) {

long checkTime = System.currentTimeMillis() + delay.toMillis();
if (checkTime > expireAt) {
return Uni.createFrom().failure(
failure.addSuppressed(
new IllegalStateException(
"Retries exhausted : " + iteration + " attempts against " + checkTime + "/" + expireAt
+ " expiration",
failure));
+ " expiration"));
return Uni.createFrom().failure(failure);
}
return Uni.createFrom().item((long) iteration).onItem().delayIt()
.onExecutor(executor).by(delay);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,24 +216,62 @@ public void testRetryWithBackOffReachingMaxAttempt() {

@Test
public void testRetryWithBackOffReachingExpiresIn() {
assertThrows(IllegalStateException.class, () -> {
assertThatThrownBy(() -> {
AtomicInteger count = new AtomicInteger();
Uni.createFrom().<String> emitter(e -> e.fail(new Exception("boom " + count.getAndIncrement())))
.onFailure().retry().withBackOff(Duration.ofMillis(10), Duration.ofSeconds(20)).withJitter(1.0)
.expireIn(90L)
.await().atMost(Duration.ofSeconds(5));
});
}).cause()
.hasMessageContaining("boom")
.satisfies(t -> assertThat(t.getSuppressed())
.hasSize(1)
.allSatisfy(s -> assertThat(s)
.isInstanceOf(IllegalStateException.class)
.hasMessageContaining("Retries exhausted")));
}

@Test
public void testRetryWithBackOffReachingExpiresAt() {
assertThrows(IllegalStateException.class, () -> {
assertThatThrownBy(() -> {
AtomicInteger count = new AtomicInteger();
Uni.createFrom().<String> emitter(e -> e.fail(new Exception("boom " + count.getAndIncrement())))
.onFailure().retry().withBackOff(Duration.ofMillis(10), Duration.ofSeconds(20)).withJitter(1.0)
.expireAt(System.currentTimeMillis() + 90L)
.await().atMost(Duration.ofSeconds(5));
});
}).cause()
.hasMessageContaining("boom")
.satisfies(t -> assertThat(t.getSuppressed())
.hasSize(1)
.allSatisfy(s -> assertThat(s)
.isInstanceOf(IllegalStateException.class)
.hasMessageContaining("Retries exhausted")));
}

@Test
public void testRetryWithBackOffReachingExpiresInPropagatesLastFailure() {
assertThatThrownBy(() -> {
AtomicInteger count = new AtomicInteger();
Uni.createFrom().<String> emitter(e -> e.fail(new Exception("boom " + count.getAndIncrement())))
.onFailure().retry().withBackOff(Duration.ofMillis(10), Duration.ofSeconds(20)).withJitter(1.0)
.expireIn(90L)
.await().atMost(Duration.ofSeconds(5));
}).isNotInstanceOf(IllegalStateException.class)
.cause()
.hasMessageContaining("boom");
}

@Test
public void testRetryWithBackOffReachingExpiresAtPropagatesLastFailure() {
assertThatThrownBy(() -> {
AtomicInteger count = new AtomicInteger();
Uni.createFrom().<String> emitter(e -> e.fail(new Exception("boom " + count.getAndIncrement())))
.onFailure().retry().withBackOff(Duration.ofMillis(10), Duration.ofSeconds(20)).withJitter(1.0)
.expireAt(System.currentTimeMillis() + 90L)
.await().atMost(Duration.ofSeconds(5));
}).isNotInstanceOf(IllegalStateException.class)
.cause()
.hasMessageContaining("boom");
}

@Test
Expand Down