Skip to content

Commit e13bebc

Browse files
committed
chore: lint and formatting compliance
1 parent bb21de7 commit e13bebc

4 files changed

Lines changed: 19 additions & 20 deletions

File tree

src/main/java/dev/openfga/sdk/api/auth/OAuth2Client.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
import dev.openfga.sdk.api.configuration.*;
55
import dev.openfga.sdk.errors.ApiException;
66
import dev.openfga.sdk.errors.FgaInvalidParameterException;
7-
import dev.openfga.sdk.telemetry.Attribute;
87
import dev.openfga.sdk.telemetry.Telemetry;
98
import java.net.URI;
109
import java.net.http.HttpRequest;
1110
import java.time.Instant;
1211
import java.util.HashMap;
13-
import java.util.Map;
14-
import java.util.concurrent.atomic.AtomicReference;
1512
import java.util.concurrent.CompletableFuture;
13+
import java.util.concurrent.atomic.AtomicReference;
1614

1715
public class OAuth2Client {
1816
private static final String DEFAULT_API_TOKEN_ISSUER_PATH = "/oauth/token";
@@ -76,10 +74,7 @@ public CompletableFuture<String> getAccessToken() throws FgaInvalidParameterExce
7674
String token = response.getAccessToken();
7775
// Write snapshot before clearing the gate so any new caller that arrives
7876
// after inFlight becomes null immediately sees a valid token.
79-
snapshot.set(
80-
new TokenSnapshot(
81-
token,
82-
Instant.now().plusSeconds(response.getExpiresInSeconds())));
77+
snapshot.set(new TokenSnapshot(token, Instant.now().plusSeconds(response.getExpiresInSeconds())));
8378

8479
telemetry.metrics().credentialsRequest(1L, new HashMap<>());
8580

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,7 @@ private static final class CredentialsCacheKey {
422422

423423
private static byte[] sha256(String value) {
424424
try {
425-
return MessageDigest.getInstance("SHA-256")
426-
.digest(value == null ? new byte[0] : value.getBytes(UTF_8));
425+
return MessageDigest.getInstance("SHA-256").digest(value == null ? new byte[0] : value.getBytes(UTF_8));
427426
} catch (NoSuchAlgorithmException e) {
428427
throw new IllegalStateException("SHA-256 not available", e);
429428
}

src/test/java/dev/openfga/sdk/api/auth/OAuth2ClientTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,16 @@ void exchangeOAuth2Token_concurrentRequests_singleExchange(WireMockRuntimeInfo w
188188

189189
for (int i = 0; i < threadCount; i++) {
190190
new Thread(() -> {
191-
try {
192-
startGate.await();
193-
tokens.add(client.getAccessToken().get());
194-
} catch (Exception e) {
195-
failures.add(e);
196-
} finally {
197-
done.countDown();
198-
}
199-
}).start();
191+
try {
192+
startGate.await();
193+
tokens.add(client.getAccessToken().get());
194+
} catch (Exception e) {
195+
failures.add(e);
196+
} finally {
197+
done.countDown();
198+
}
199+
})
200+
.start();
200201
}
201202

202203
startGate.countDown();

src/test/java/dev/openfga/sdk/api/client/ApiClientTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,15 @@ void clientCredentials_differentCredentials_exchangeSeparateTokens() throws Exce
253253

254254
HttpRequest.Builder requestA = HttpRequest.newBuilder().uri(URI.create(FgaConstants.TEST_API_URL));
255255
apiClient.applyAuthHeader(requestA, configA);
256-
assertEquals("Bearer " + tokenA, requestA.build().headers().firstValue("Authorization").orElseThrow());
256+
assertEquals(
257+
"Bearer " + tokenA,
258+
requestA.build().headers().firstValue("Authorization").orElseThrow());
257259

258260
HttpRequest.Builder requestB = HttpRequest.newBuilder().uri(URI.create(FgaConstants.TEST_API_URL));
259261
apiClient.applyAuthHeader(requestB, configB);
260-
assertEquals("Bearer " + tokenB, requestB.build().headers().firstValue("Authorization").orElseThrow());
262+
assertEquals(
263+
"Bearer " + tokenB,
264+
requestB.build().headers().firstValue("Authorization").orElseThrow());
261265

262266
// Each issuer is hit exactly once — no cross-contamination.
263267
mockHttpClient.verify().post(issuerA + "/oauth/token").called(1);

0 commit comments

Comments
 (0)