Skip to content

Commit

Permalink
Using SocketException in all of the OIDC retry code
Browse files Browse the repository at this point in the history
  • Loading branch information
sberyozkin committed Mar 5, 2025
1 parent db7df2e commit 18871a2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.net.ConnectException;
import java.net.MalformedURLException;
import java.net.ServerSocket;
import java.net.SocketException;
import java.net.URI;
import java.net.URL;
import java.nio.file.Files;
Expand Down Expand Up @@ -814,7 +814,7 @@ public int getErrorStatus() {
}

private static Predicate<? super Throwable> realmEndpointNotAvailable() {
return t -> (t instanceof ConnectException
return t -> (t instanceof SocketException
|| (t instanceof RealmEndpointAccessException && ((RealmEndpointAccessException) t).getErrorStatus() == 404));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static io.quarkus.jsonp.JsonProviderHolder.jsonProvider;

import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -163,7 +163,7 @@ static UniOnItem<HttpResponse<Buffer>> postRequest(OidcRequestContextProperties
// Retry up to three times with a one-second delay between the retries if the connection is closed
Buffer buffer = Buffer.buffer(clientRegJson);
Uni<HttpResponse<Buffer>> response = filterHttpRequest(requestProps, request, filters, buffer).sendBuffer(buffer)
.onFailure(ConnectException.class)
.onFailure(SocketException.class)
.retry()
.atMost(oidcConfig.connectionRetryCount())
.onFailure().transform(t -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static io.quarkus.jsonp.JsonProviderHolder.jsonProvider;

import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketException;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -162,7 +162,7 @@ private UniOnItem<HttpResponse<Buffer>> makeRequest(OidcRequestContextProperties
}
// Retry up to three times with a one-second delay between the retries if the connection is closed
Uni<HttpResponse<Buffer>> response = filterHttpRequest(requestProps, request, buffer).sendBuffer(buffer)
.onFailure(ConnectException.class)
.onFailure(SocketException.class)
.retry()
.atMost(oidcConfig.connectionRetryCount())
.onFailure().transform(t -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.quarkus.oidc.client.runtime;

import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketException;
import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.time.Instant;
Expand Down Expand Up @@ -244,7 +244,7 @@ private UniOnItem<HttpResponse<Buffer>> postRequest(
// Retry up to three times with a one-second delay between the retries if the connection is closed
Buffer buffer = OidcCommonUtils.encodeForm(body);
Uni<HttpResponse<Buffer>> response = filterHttpRequest(requestProps, endpointType, request, buffer).sendBuffer(buffer)
.onFailure(ConnectException.class)
.onFailure(SocketException.class)
.retry()
.atMost(oidcConfig.connectionRetryCount())
.onFailure().transform(t -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ConnectException;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.URI;
import java.net.URLEncoder;
import java.net.UnknownHostException;
Expand Down Expand Up @@ -514,7 +514,7 @@ public static Key initClientJwtKey(OidcClientCommonConfig oidcConfig, boolean se
}

public static Predicate<? super Throwable> oidcEndpointNotAvailable() {
return t -> (t instanceof ConnectException
return t -> (t instanceof SocketException
|| (t instanceof OidcEndpointAccessException && ((OidcEndpointAccessException) t).getErrorStatus() == 404));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.quarkus.oidc.runtime;

import java.io.Closeable;
import java.net.ConnectException;
import java.net.SocketException;
import java.security.Key;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -346,7 +346,7 @@ private UniOnItem<HttpResponse<Buffer>> getHttpResponse(OidcRequestContextProper

OidcEndpoint.Type endpoint = introspect ? OidcEndpoint.Type.INTROSPECTION : OidcEndpoint.Type.TOKEN;
Uni<HttpResponse<Buffer>> response = filterHttpRequest(requestProps, endpoint, request, buffer).sendBuffer(buffer)
.onFailure(ConnectException.class)
.onFailure(SocketException.class)
.retry()
.atMost(oidcConfig.connectionRetryCount()).onFailure().transform(Throwable::getCause);
return response.onItem();
Expand Down

0 comments on commit 18871a2

Please sign in to comment.