From 02d5a1a49e38df90239f6bc53f8e1aeeef620709 Mon Sep 17 00:00:00 2001 From: Julien Ponge Date: Tue, 27 Feb 2024 20:55:45 +0100 Subject: [PATCH] refactor(UniRetry): use direct value Uni objects rather than emitters --- .../java/io/smallrye/mutiny/groups/UniRetry.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/implementation/src/main/java/io/smallrye/mutiny/groups/UniRetry.java b/implementation/src/main/java/io/smallrye/mutiny/groups/UniRetry.java index 2ff8f81a3..ed359f4d8 100644 --- a/implementation/src/main/java/io/smallrye/mutiny/groups/UniRetry.java +++ b/implementation/src/main/java/io/smallrye/mutiny/groups/UniRetry.java @@ -140,18 +140,17 @@ public Uni expireIn(long expireIn) { public Uni until(Predicate predicate) { ParameterValidation.nonNull(predicate, "predicate"); Function, Flow.Publisher> whenStreamFactory = stream -> stream.onItem() - .transformToUni(failure -> Uni.createFrom(). 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); }