Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't allow user to set project id or namespace to null #269

Merged
Merged
Show file tree
Hide file tree
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 @@ -122,7 +122,8 @@ protected B self() {
}

public B projectId(String projectId) {
this.projectId = projectId;
this.projectId =
checkNotNull(projectId, "Project ID cannot be set to null. Leave unset for default.");
return self();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.google.gcloud.datastore;

import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;

/**
Expand All @@ -29,14 +28,14 @@ public final class KeyFactory extends BaseKey.Builder<KeyFactory> {
private final String ns;

public KeyFactory(String projectId) {
this(projectId, null);
this(projectId, "");
}

public KeyFactory(String projectId, String namespace) {
super(projectId);
namespace(namespace);
this.pi = projectId;
this.ns = MoreObjects.firstNonNull(namespace, "");
this.ns = namespace;
}

public IncompleteKey newKey() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ static String validateDatabase(String projectId) {
}

static String validateNamespace(String namespace) {
if (Strings.isNullOrEmpty(namespace)) {
return "";
}
checkArgument(namespace != null, "Namespace cannot be null. Leave unset for default.");
checkArgument(namespace.length() <= MAX_NAMESPACE_LENGTH,
"namespace must not contain more than 100 characters");
checkArgument(NAMESPACE_PATTERN.matcher(namespace).matches(),
Expand Down