From 668a80f82fe8c5a10d2c84834862452fcded398a Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Thu, 26 Mar 2020 21:03:23 +0900 Subject: [PATCH] Use retryWhen() in StatsdMeterRegistry --- .../main/java/io/micrometer/statsd/StatsdMeterRegistry.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/implementations/micrometer-registry-statsd/src/main/java/io/micrometer/statsd/StatsdMeterRegistry.java b/implementations/micrometer-registry-statsd/src/main/java/io/micrometer/statsd/StatsdMeterRegistry.java index 769b9d4fef..809df2b121 100644 --- a/implementations/micrometer-registry-statsd/src/main/java/io/micrometer/statsd/StatsdMeterRegistry.java +++ b/implementations/micrometer-registry-statsd/src/main/java/io/micrometer/statsd/StatsdMeterRegistry.java @@ -37,6 +37,7 @@ import reactor.netty.tcp.TcpClient; import reactor.netty.udp.UdpClient; import reactor.util.context.Context; +import reactor.util.retry.Retry; import java.net.PortUnreachableException; import java.time.Duration; @@ -223,7 +224,7 @@ private void prepareUdpClient(Publisher publisher) { .handle((in, out) -> out .sendString(publisher) .neverComplete() - .retry(throwable -> throwable instanceof PortUnreachableException) + .retryWhen(Retry.indefinitely().filter(throwable -> throwable instanceof PortUnreachableException)) ) .connect() .subscribe(client -> { @@ -254,7 +255,7 @@ private void connectAndSubscribe(TcpClient tcpClient) { } return Mono.empty(); }) - .retryBackoff(Long.MAX_VALUE, Duration.ofSeconds(1), Duration.ofMinutes(1)) + .retryWhen(Retry.backoff(Long.MAX_VALUE, Duration.ofSeconds(1)).maxBackoff(Duration.ofMinutes(1))) .subscribe(client -> { this.client.replace(client);