Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.cloud.spanner.SpannerExceptionFactory;
import com.google.cloud.spanner.admin.instance.v1.stub.GrpcInstanceAdminStub;
import com.google.cloud.spanner.admin.instance.v1.stub.InstanceAdminStubSettings;
import com.google.common.base.Strings;
import com.google.spanner.admin.instance.v1.ListInstanceConfigsRequest;
import java.time.Duration;

Expand All @@ -42,14 +43,18 @@ class LocalConnectionChecker {
void checkLocalConnection(ConnectionOptions options) {
final String emulatorHost = System.getenv("SPANNER_EMULATOR_HOST");
String host = options.getHost() == null ? emulatorHost : options.getHost();
if (Strings.isNullOrEmpty(host)) {
return;
}

if (host.startsWith("https://")) {
host = host.substring(8);
}
if (host.startsWith("http://")) {
host = host.substring(7);
}
// Only do the check if the host has been set to localhost.
if (host != null && host.startsWith("localhost") && options.isUsePlainText()) {
if (host.startsWith("localhost") && options.isUsePlainText()) {
// Do a quick check to see if anything is actually running on the host.
try {
InstanceAdminStubSettings.Builder testEmulatorSettings =
Expand Down
Loading