diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java b/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java index 59c2d57fb3df..206e1fecaa58 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java @@ -154,7 +154,7 @@ public B serviceRpcFactory(ServiceRpcFactory serviceRpcFa protected ServiceOptions(Builder builder) { projectId = checkNotNull(builder.projectId != null ? builder.projectId : defaultProject()); - host = firstNonNull(builder.host, DEFAULT_HOST); + host = firstNonNull(builder.host, defaultHost()); httpTransportFactory = firstNonNull(builder.httpTransportFactory, DefaultHttpTransportFactory.INSTANCE); authCredentials = firstNonNull(builder.authCredentials, defaultAuthCredentials()); @@ -191,6 +191,10 @@ protected static String appEngineAppId() { return System.getProperty("com.google.appengine.application.id"); } + protected String defaultHost() { + return DEFAULT_HOST; + } + protected String defaultProject() { String projectId = System.getProperty(PROJECT_ENV_NAME, System.getenv(PROJECT_ENV_NAME)); if (projectId == null) { diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreOptions.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreOptions.java index c670bb5d9a2d..7b0dd3a2a606 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreOptions.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreOptions.java @@ -38,6 +38,7 @@ public class DatastoreOptions extends ServiceOptions SCOPES = ImmutableSet.of(DATASTORE_SCOPE, USERINFO_SCOPE); @@ -122,6 +123,12 @@ private DatastoreOptions normalize() { } } + @Override + protected String defaultHost() { + String host = System.getProperty(HOST_ENV_NAME, System.getenv(HOST_ENV_NAME)); + return host != null ? host : super.defaultHost(); + } + @Override protected String defaultProject() { String projectId = System.getProperty(DATASET_ENV_NAME, System.getenv(DATASET_ENV_NAME));