Skip to content

Commit 673855e

Browse files
authored
feat: use dummy emulator-project when no project is set (#1363)
Use a dummy emulator-project when no default project is set for the environment and the SPANNER_EMULATOR_HOST environment variable has been set. Replaces #1345
1 parent 8951c8c commit 673855e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java

+10
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,16 @@ public static void useDefaultEnvironment() {
11641164
SpannerOptions.environment = SpannerEnvironmentImpl.INSTANCE;
11651165
}
11661166

1167+
@Override
1168+
protected String getDefaultProject() {
1169+
String projectId = getDefaultProjectId();
1170+
// The project id does not matter if we are using the emulator.
1171+
if (projectId == null && System.getenv("SPANNER_EMULATOR_HOST") != null) {
1172+
return "emulator-project";
1173+
}
1174+
return projectId;
1175+
}
1176+
11671177
public TransportChannelProvider getChannelProvider() {
11681178
return channelProvider;
11691179
}

0 commit comments

Comments
 (0)