Skip to content

Commit 153c570

Browse files
committed
fix: rename method and use runAsync instead of supplyAsync
1 parent 3e6489b commit 153c570

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/main/java/dev/openfga/sdk/api/client/HttpRequestAttempt.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ public CompletableFuture<ApiResponse<T>> attemptHttpRequest() throws ApiExceptio
8080
addTelemetryAttribute(Attributes.HTTP_REQUEST_METHOD, request.method());
8181
addTelemetryAttribute(Attributes.USER_AGENT, configuration.getUserAgent());
8282

83-
return attemptHttpRequest(createClient(), 0, null);
83+
return attemptHttpRequest(getHttpClient(), 0, null);
8484
}
8585

86-
private HttpClient createClient() {
86+
private HttpClient getHttpClient() {
8787
return apiClient.getHttpClient();
8888
}
8989

@@ -140,16 +140,14 @@ private CompletableFuture<ApiResponse<T>> handleHttpErrorRetry(
140140
private CompletableFuture<ApiResponse<T>> delayedRetry(
141141
Duration retryDelay, int nextRetryNumber, Throwable previousError) {
142142
// Use CompletableFuture.delayedExecutor() to delay the retry attempt itself
143-
return CompletableFuture.supplyAsync(
143+
return CompletableFuture.runAsync(
144144
() -> {
145-
// We don't need a return value, just the delay
146-
return null;
145+
// No-op task, we only care about the delay timing
147146
},
148147
CompletableFuture.delayedExecutor(retryDelay.toNanos(), TimeUnit.NANOSECONDS))
149148
.thenCompose(ignored -> {
150-
// Reuse the existing HttpClient instead of creating a new one for efficiency
151-
HttpClient reusableClient = apiClient.getHttpClient();
152-
return attemptHttpRequest(reusableClient, nextRetryNumber, previousError);
149+
// Get HttpClient when needed (just returns cached instance)
150+
return attemptHttpRequest(getHttpClient(), nextRetryNumber, previousError);
153151
});
154152
}
155153

0 commit comments

Comments
 (0)