Skip to content

Commit

Permalink
Merge pull request #1526 from smallrye/refactor/UniRetry-until-use-di…
Browse files Browse the repository at this point in the history
…rect-unis

refactor(UniRetry): use direct value Uni objects rather than emitters
  • Loading branch information
jponge authored Feb 27, 2024
2 parents 7b57fe7 + 02d5a1a commit cc800eb
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 cc800eb

Please sign in to comment.