From 6bc44e66a9bb9603a530512923a13e0ee483111a Mon Sep 17 00:00:00 2001 From: Samuel Cox Date: Wed, 10 Aug 2022 13:32:42 -0500 Subject: [PATCH] [2425] handle redirects separately to always retry those (is that really true?) #2425 --- .../netty/http/client/HttpClientConnect.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClientConnect.java b/reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClientConnect.java index b2fa611509..df08542bc5 100644 --- a/reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClientConnect.java +++ b/reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClientConnect.java @@ -55,7 +55,6 @@ import reactor.netty.Connection; import reactor.netty.ConnectionObserver; import reactor.netty.NettyOutbound; -import reactor.netty.channel.AbortedException; import reactor.netty.http.HttpOperations; import reactor.netty.http.HttpProtocol; import reactor.netty.resources.ConnectionProvider; @@ -270,8 +269,19 @@ public void subscribe(CoreSubscriber actual) { .acquire(_config, observer, handler, resolver) .subscribe(new ClientTransportSubscriber(sink)); - }).retryWhen(Retry.max(config.retryConfig.maxRetries).filter(handler)) - .subscribe(actual); + // TODO definitely not happy about spreading the retry logic even more + }).retryWhen(Retry.indefinitely().filter(err -> { + if (err instanceof RedirectClientException) { + RedirectClientException re = (RedirectClientException)err; + if (HttpResponseStatus.SEE_OTHER.equals(re.status)) { + handler.method = HttpMethod.GET; + } + handler.redirect(re.location); + return true; + } + return false; + })).retryWhen(Retry.max(config.retryConfig.maxRetries).filter(handler)) + .subscribe(actual); } private void removeIncompatibleProtocol(HttpClientConfig config, HttpProtocol protocol) { @@ -680,14 +690,6 @@ void channel(HttpClientOperations ops) { @Override public boolean test(Throwable throwable) { - if (throwable instanceof RedirectClientException) { - RedirectClientException re = (RedirectClientException) throwable; - if (HttpResponseStatus.SEE_OTHER.equals(re.status)) { - method = HttpMethod.GET; - } - redirect(re.location); - return true; - } if (shouldRetry && canRetry(throwable)) { redirect(toURI.toString()); return true;