Skip to content

Commit

Permalink
refactor(UniRetry): use direct value Uni objects rather than emitters
Browse files Browse the repository at this point in the history
  • Loading branch information
jponge committed Feb 27, 2024
1 parent 7b57fe7 commit 02d5a1a
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,17 @@ public Uni<T> expireIn(long expireIn) {
public Uni<T> until(Predicate<? super Throwable> predicate) {
ParameterValidation.nonNull(predicate, "predicate");
Function<Multi<Throwable>, Flow.Publisher<Long>> whenStreamFactory = stream -> stream.onItem()
.transformToUni(failure -> Uni.createFrom().<Long> emitter(emitter -> {
.transformToUniAndConcatenate(failure -> {
try {
if (predicate.test(failure)) {
emitter.complete(1L);
return Uni.createFrom().item(1L);
} else {
emitter.fail(failure);
return Uni.createFrom().failure(failure);
}
} catch (Throwable ex) {
emitter.fail(ex);
} catch (Throwable err) {
return Uni.createFrom().failure(err);
}
}))
.concatenate();
});
return when(whenStreamFactory);
}

Expand Down

0 comments on commit 02d5a1a

Please sign in to comment.