Skip to content

Commit

Permalink
Change How the Netty HttpClient Implementation Handles SSLException (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alzimmermsft authored Apr 16, 2021
1 parent 9e0aa62 commit 48a8e81
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import reactor.netty.http.client.HttpClientResponse;
import reactor.util.retry.Retry;

import javax.net.ssl.SSLException;
import java.nio.ByteBuffer;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -82,6 +83,17 @@ public Mono<HttpResponse> send(HttpRequest request, Context context) {
.send(bodySendDelegate(request))
.responseConnection(responseDelegate(request, disableBufferCopy, eagerlyReadResponse))
.single()
.onErrorMap(throwable -> {
// The exception was an SSLException that was caused by a failure to connect to a proxy.
// Extract the inner ProxyConnectException and propagate that instead.
if (throwable instanceof SSLException) {
if (throwable.getCause() instanceof ProxyConnectException) {
return throwable.getCause();
}
}

return throwable;
})
.retryWhen(Retry.max(1).filter(throwable -> throwable instanceof ProxyConnectException)
.onRetryExhaustedThrow((ignoredSpec, signal) -> signal.failure()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import com.azure.core.http.ProxyOptions;
import com.azure.core.http.netty.implementation.ChallengeHolder;
import com.azure.core.http.netty.implementation.HttpProxyExceptionHandler;
import com.azure.core.http.netty.implementation.HttpProxyHandler;
import com.azure.core.http.netty.implementation.ReadTimeoutHandler;
import com.azure.core.http.netty.implementation.ResponseTimeoutHandler;
Expand Down Expand Up @@ -149,8 +148,7 @@ public com.azure.core.http.HttpClient build() {
channel.pipeline()
.addFirst(NettyPipeline.ProxyHandler, new HttpProxyHandler(
AddressUtils.replaceWithResolved(buildProxyOptions.getAddress()),
handler, proxyChallengeHolder))
.addLast("azure.proxy.exceptionHandler", new HttpProxyExceptionHandler());
handler, proxyChallengeHolder));
}
});

Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 48a8e81

Please sign in to comment.