Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

Commit b802f0a

Browse files
committed
suggestions from gemini review + lint fixes
1 parent e871f0f commit b802f0a

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/MutableCredentials.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
* A mutable {@link Credentials} implementation that delegates authentication behavior to a scoped
2727
* {@link ServiceAccountCredentials} instance.
2828
*
29-
* <p>This class is intended for scenarios where an application needs to rotate or replace the
30-
* underlying service account credentials for a running Spanner Client.
29+
* <p>This class is intended for scenarios where an application needs to replace the underlying
30+
* service account credentials for a long running Spanner Client.
3131
*
3232
* <p>All operations inherited from {@link Credentials} are forwarded to the current delegate,
3333
* including request metadata retrieval and token refresh. Calling {@link
@@ -36,8 +36,8 @@
3636
* constructed.
3737
*/
3838
public class MutableCredentials extends Credentials {
39-
ServiceAccountCredentials delegate;
40-
List<String> scopes;
39+
private volatile ServiceAccountCredentials delegate;
40+
private final List<String> scopes;
4141

4242

4343
public MutableCredentials(ServiceAccountCredentials credentials, List<String> scopes) {

google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ITMutableCredentialsTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ public void testMutableCredentialsUpdateAuthorizationForRunningClient() throws I
9292
}
9393
}
9494
}
95+

google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/MutableCredentialsTest.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ public class MutableCredentialsTest {
5252
String updatedAuthType = "auth-2";
5353

5454
@Test
55-
public void testCreateMutableCredentialsAndUpdate() throws IOException {
55+
public void testCreateMutableCredentials() throws IOException {
5656
setupInitialCredentials();
57-
setupUpdatedCredentials();
5857

5958
MutableCredentials credentials = new MutableCredentials(initialCredentials, scopes);
6059

@@ -68,6 +67,16 @@ public void testCreateMutableCredentialsAndUpdate() throws IOException {
6867
credentials.refresh();
6968

7069
verify(initialScopedCredentials, times(1)).refresh();
70+
}
71+
72+
@Test
73+
public void testUpdateMutableCredentials() throws IOException {
74+
setupInitialCredentials();
75+
setupUpdatedCredentials();
76+
77+
MutableCredentials credentials = new MutableCredentials(initialCredentials, scopes);
78+
79+
assertEquals(initialAuthType, credentials.getAuthenticationType());
7180

7281
credentials.updateCredentials(updatedCredentials);
7382

@@ -97,3 +106,4 @@ private void setupUpdatedCredentials() throws IOException {
97106
when(updatedScopedCredentials.hasRequestMetadataOnly()).thenReturn(false);
98107
}
99108
}
109+

0 commit comments

Comments
 (0)