From 44c628e4feb3b0de3711800b6fca2c5b6051a1c9 Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Wed, 8 Oct 2025 13:58:17 -0400 Subject: [PATCH 1/5] fix: Migrate away from GoogleCredentials.fromStream() usages --- .../cloud/spanner/connection/CredentialsServiceTest.java | 8 +++++--- .../com/google/cloud/spanner/it/ITVPCNegativeTest.java | 5 +---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/CredentialsServiceTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/CredentialsServiceTest.java index e8dc7a4f875..7c82a32de66 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/CredentialsServiceTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/CredentialsServiceTest.java @@ -25,8 +25,9 @@ import com.google.auth.oauth2.ServiceAccountCredentials; import com.google.cloud.spanner.ErrorCode; import com.google.cloud.spanner.SpannerException; -import java.io.FileInputStream; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -36,7 +37,7 @@ public class CredentialsServiceTest { private static final String FILE_TEST_PATH = CredentialsServiceTest.class.getResource("test-key.json").getFile(); - private static final String APP_DEFAULT_FILE_TEST_PATH = + private static final String SA_APP_DEFAULT_FILE_TEST_PATH = CredentialsServiceTest.class.getResource("test-key-app-default.json").getFile(); private static final String TEST_PROJECT_ID = "test-project"; @@ -49,7 +50,8 @@ public class CredentialsServiceTest { GoogleCredentials internalGetApplicationDefault() throws IOException { // Read application default credentials directly from a specific file instead of actually // fetching the default from the environment. - return GoogleCredentials.fromStream(new FileInputStream(APP_DEFAULT_FILE_TEST_PATH)); + return ServiceAccountCredentials.fromStream( + Files.newInputStream(Paths.get(SA_APP_DEFAULT_FILE_TEST_PATH))); } }; diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITVPCNegativeTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITVPCNegativeTest.java index 09e03cbca0c..0a0e53a887f 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITVPCNegativeTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITVPCNegativeTest.java @@ -48,7 +48,6 @@ import com.google.common.base.Strings; import com.google.longrunning.OperationsClient; import com.google.longrunning.OperationsSettings; -import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -352,9 +351,7 @@ public void deniedListBackupOperations() throws IOException { .setTransportChannelProvider(InstantiatingGrpcChannelProvider.newBuilder().build()) .setEndpoint("spanner.googleapis.com:443") .setCredentialsProvider( - FixedCredentialsProvider.create( - GoogleCredentials.fromStream( - new FileInputStream(System.getenv("GOOGLE_APPLICATION_CREDENTIALS"))))) + FixedCredentialsProvider.create(GoogleCredentials.getApplicationDefault())) .build())) { client.listOperations(backupId.getName() + "/operations", ""); fail("Expected PermissionDeniedException"); From 974e7fab5f57da45847395e576f3f176127deff4 Mon Sep 17 00:00:00 2001 From: cloud-java-bot Date: Wed, 8 Oct 2025 18:02:09 +0000 Subject: [PATCH 2/5] chore: generate libraries at Wed Oct 8 17:59:33 UTC 2025 --- .github/workflows/update_generation_config.yaml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_generation_config.yaml b/.github/workflows/update_generation_config.yaml index 59e39834dd0..a7e14bb483c 100644 --- a/.github/workflows/update_generation_config.yaml +++ b/.github/workflows/update_generation_config.yaml @@ -26,7 +26,7 @@ jobs: # the branch into which the pull request is merged base_branch: main steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} diff --git a/README.md b/README.md index 6fc3af24e73..1834946ad1e 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file: com.google.cloud libraries-bom - 26.68.0 + 26.69.0 pom import From e024deb55ec81b075161ad4d427a37d5b5893cd3 Mon Sep 17 00:00:00 2001 From: cloud-java-bot Date: Fri, 10 Oct 2025 04:49:21 +0000 Subject: [PATCH 3/5] chore: generate libraries at Fri Oct 10 04:46:45 UTC 2025 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 09bdb791d8a..0aa66b78751 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file: com.google.cloud libraries-bom - 26.69.0 + 26.70.0 pom import From e3b3a622248d225a5f19829bd87b03b91738cace Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Mon, 13 Oct 2025 10:58:47 -0400 Subject: [PATCH 4/5] chore: Resolve issue with Paths.get() --- .../cloud/spanner/connection/CredentialsServiceTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/CredentialsServiceTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/CredentialsServiceTest.java index 7c82a32de66..e3d0c19a9fa 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/CredentialsServiceTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/CredentialsServiceTest.java @@ -25,9 +25,9 @@ import com.google.auth.oauth2.ServiceAccountCredentials; import com.google.cloud.spanner.ErrorCode; import com.google.cloud.spanner.SpannerException; +import java.io.File; import java.io.IOException; import java.nio.file.Files; -import java.nio.file.Paths; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -36,9 +36,9 @@ @RunWith(JUnit4.class) public class CredentialsServiceTest { private static final String FILE_TEST_PATH = - CredentialsServiceTest.class.getResource("test-key.json").getFile(); + CredentialsServiceTest.class.getResource("test-key.json").getPath(); private static final String SA_APP_DEFAULT_FILE_TEST_PATH = - CredentialsServiceTest.class.getResource("test-key-app-default.json").getFile(); + CredentialsServiceTest.class.getResource("test-key-app-default.json").getPath(); private static final String TEST_PROJECT_ID = "test-project"; private static final String APP_DEFAULT_PROJECT_ID = "app-default-test-project"; @@ -51,7 +51,7 @@ GoogleCredentials internalGetApplicationDefault() throws IOException { // Read application default credentials directly from a specific file instead of actually // fetching the default from the environment. return ServiceAccountCredentials.fromStream( - Files.newInputStream(Paths.get(SA_APP_DEFAULT_FILE_TEST_PATH))); + Files.newInputStream(new File(SA_APP_DEFAULT_FILE_TEST_PATH).toPath())); } }; From cb3771596f730097279f300319755c00ce5041d1 Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Mon, 13 Oct 2025 11:30:13 -0400 Subject: [PATCH 5/5] chore: Add comment for fixed test --- .../cloud/spanner/connection/CredentialsServiceTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/CredentialsServiceTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/CredentialsServiceTest.java index e3d0c19a9fa..7b7c41817e4 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/CredentialsServiceTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/CredentialsServiceTest.java @@ -51,6 +51,9 @@ GoogleCredentials internalGetApplicationDefault() throws IOException { // Read application default credentials directly from a specific file instead of actually // fetching the default from the environment. return ServiceAccountCredentials.fromStream( + // Calling `getResource().getPath()` on Windows returns a string that might start with + // something like `/C:/...`. Paths.get() interprets the leading / as part of the path + // and would be invalid. Use `new File().toPath()` to read from these files. Files.newInputStream(new File(SA_APP_DEFAULT_FILE_TEST_PATH).toPath())); } };