Skip to content

Commit

Permalink
[2425] handle redirects separately to always retry those (is that really
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Cox committed Aug 10, 2022
1 parent 35103d4 commit c607fe4
Showing 1 changed file with 13 additions and 11 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -270,8 +269,19 @@ public void subscribe(CoreSubscriber<? super Connection> 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) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c607fe4

Please sign in to comment.