Skip to content

Commit c72e474

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 6847 b: refs/heads/tswast-patch-1 c: 03ca1bf h: refs/heads/master i: 6845: aca9ee4 6843: 67548a1 6839: fbf1fc9 6831: 0e7c814 6815: a203d4f 6783: 2e110e9
1 parent 343c1d1 commit c72e474

3 files changed

Lines changed: 6 additions & 19 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: f11195303f281414fa10b74ca402c0a99bf77313
60+
refs/heads/tswast-patch-1: 03ca1bfbf214900f5c0dbd06fb982fe396425426
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Cursor.java

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,14 @@
1717
package com.google.gcloud.datastore;
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
20-
import static java.nio.charset.StandardCharsets.UTF_8;
2120

2221
import com.google.api.services.datastore.DatastoreV1;
2322
import com.google.api.services.datastore.DatastoreV1.Value;
2423
import com.google.common.base.MoreObjects;
2524
import com.google.common.base.MoreObjects.ToStringHelper;
25+
import com.google.common.io.BaseEncoding;
2626
import com.google.protobuf.ByteString;
2727
import com.google.protobuf.InvalidProtocolBufferException;
28-
import com.google.protobuf.TextFormat;
29-
import com.google.protobuf.TextFormat.ParseException;
30-
31-
import java.io.UnsupportedEncodingException;
32-
import java.net.URLDecoder;
33-
import java.net.URLEncoder;
3428

3529
/**
3630
* A Google Cloud Datastore cursor.
@@ -74,23 +68,16 @@ ByteString byteString() {
7468
* Returns the cursor in an encoded form that can be used as part of a URL.
7569
*/
7670
public String toUrlSafe() {
77-
try {
78-
return URLEncoder.encode(TextFormat.printToString(toPb()), UTF_8.name());
79-
} catch (UnsupportedEncodingException e) {
80-
throw new IllegalStateException("Unexpected encoding exception", e);
81-
}
71+
return BaseEncoding.base64Url().encode(byteString.toByteArray());
8272
}
8373

8474
/**
8575
* Create a {@code Cursor} given its URL safe encoded form.
8676
*/
8777
public static Cursor fromUrlSafe(String urlSafe) {
8878
try {
89-
String utf8Str = URLDecoder.decode(urlSafe, UTF_8.name());
90-
DatastoreV1.Value.Builder builder = DatastoreV1.Value.newBuilder();
91-
TextFormat.merge(utf8Str, builder);
92-
return fromPb(builder.build());
93-
} catch (UnsupportedEncodingException | ParseException e) {
79+
return Cursor.copyFrom(BaseEncoding.base64Url().decode(urlSafe));
80+
} catch (IllegalArgumentException e) {
9481
throw new IllegalStateException("Unexpected decoding exception", e);
9582
}
9683
}

branches/tswast-patch-1/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/StructuredQuery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ public StructuredQuery<V> build() {
782782
}
783783
}
784784

785-
static final class Builder<V> extends BaseBuilder<V, Builder<V>> {
785+
public static final class Builder<V> extends BaseBuilder<V, Builder<V>> {
786786

787787
Builder(ResultType<V> resultType) {
788788
super(resultType);

0 commit comments

Comments
 (0)