Skip to content

Commit

Permalink
Make projectIdRequired() method protected. Also supply nice error mes…
Browse files Browse the repository at this point in the history
…sage if project could not be determined and is required
  • Loading branch information
Ajay Kannan committed Nov 10, 2015
1 parent ad12f41 commit 6c40825
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.google.gcloud;

import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkArgument;
import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.api.client.extensions.appengine.http.UrlFetchTransport;
Expand Down Expand Up @@ -308,7 +308,10 @@ protected ServiceOptions(Class<? extends ServiceFactory<ServiceT, OptionsT>> ser
Builder<ServiceT, ServiceRpcT, OptionsT, ?> builder) {
projectId = builder.projectId != null ? builder.projectId : defaultProject();
if (projectIdRequired()) {
checkNotNull(projectId);
checkArgument(
projectId != null,
"A project ID is required for this service but could not be determined from the builder or "
+ "the environment. Please set a project ID using the builder.");
}
host = firstNonNull(builder.host, defaultHost());
httpTransportFactory = firstNonNull(builder.httpTransportFactory,
Expand All @@ -334,7 +337,7 @@ protected ServiceOptions(Class<? extends ServiceFactory<ServiceT, OptionsT>> ser
*
* @return true if a project ID is required to use the service, false if not.
*/
public boolean projectIdRequired() {
protected boolean projectIdRequired() {
return true;
}

Expand Down

0 comments on commit 6c40825

Please sign in to comment.