Skip to content

Commit 67b34cf

Browse files
committed
Merge branch 'main' of github.com:googleapis/java-spanner into uuid_cloud_client_executor
2 parents 62da614 + 603a79d commit 67b34cf

File tree

9 files changed

+78
-19
lines changed

9 files changed

+78
-19
lines changed

.github/workflows/unmanaged_dependency_check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ jobs:
1717
# repository
1818
.kokoro/build.sh
1919
- name: Unmanaged dependency check
20-
uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.45.1
20+
uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.46.2
2121
with:
2222
bom-path: google-cloud-spanner-bom/pom.xml

.kokoro/build.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ integration)
9898
-Dclirr.skip=true \
9999
-Denforcer.skip=true \
100100
-Dmaven.main.skip=true \
101-
-Dspanner.gce.config.server_url=https://staging-wrenchworks.sandbox.googleapis.com \
102-
-Dspanner.gce.config.project_id=span-cloud-testing \
103-
-Dspanner.testenv.instance=projects/span-cloud-testing/instances/java-client-integration-tests \
101+
-Dspanner.gce.config.project_id=gcloud-devel \
102+
-Dspanner.testenv.instance=projects/gcloud-devel/instances/java-client-integration-tests \
104103
-fae \
105104
verify
106105
RETURN_CODE=$?
@@ -114,7 +113,6 @@ integration-directpath-enabled)
114113
-Dclirr.skip=true \
115114
-Denforcer.skip=true \
116115
-Dmaven.main.skip=true \
117-
-Dspanner.gce.config.server_url=https://staging-wrenchworks.sandbox.googleapis.com \
118116
-Dspanner.testenv.instance=projects/span-cloud-testing/instances/spanner-java-client-directpath \
119117
-Dspanner.gce.config.project_id=span-cloud-testing \
120118
-fae \
@@ -130,9 +128,8 @@ integration-multiplexed-sessions-enabled)
130128
-Dclirr.skip=true \
131129
-Denforcer.skip=true \
132130
-Dmaven.main.skip=true \
133-
-Dspanner.gce.config.server_url=https://staging-wrenchworks.sandbox.googleapis.com \
134-
-Dspanner.gce.config.project_id=span-cloud-testing \
135-
-Dspanner.testenv.instance=projects/span-cloud-testing/instances/java-client-integration-tests-multiplexed-sessions \
131+
-Dspanner.gce.config.project_id=gcloud-devel \
132+
-Dspanner.testenv.instance=projects/gcloud-devel/instances/java-client-integration-tests-multiplexed-sessions \
136133
-fae \
137134
verify
138135
RETURN_CODE=$?

.kokoro/presubmit/integration-directpath-enabled.cfg

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ env_vars: {
1111
value: "integration-directpath-enabled"
1212
}
1313

14+
# TODO: remove this after we've migrated all tests and scripts
15+
env_vars: {
16+
key: "GCLOUD_PROJECT"
17+
value: "gcloud-devel"
18+
}
19+
20+
env_vars: {
21+
key: "GOOGLE_CLOUD_PROJECT"
22+
value: "gcloud-devel"
23+
}
24+
1425
env_vars: {
1526
key: "GOOGLE_APPLICATION_CREDENTIALS"
1627
value: "secret_manager/java-client-testing"

.kokoro/presubmit/integration-multiplexed-sessions-enabled.cfg

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,25 @@ env_vars: {
1111
value: "integration-multiplexed-sessions-enabled"
1212
}
1313

14+
# TODO: remove this after we've migrated all tests and scripts
15+
env_vars: {
16+
key: "GCLOUD_PROJECT"
17+
value: "gcloud-devel"
18+
}
19+
20+
env_vars: {
21+
key: "GOOGLE_CLOUD_PROJECT"
22+
value: "gcloud-devel"
23+
}
24+
1425
env_vars: {
1526
key: "GOOGLE_APPLICATION_CREDENTIALS"
16-
value: "secret_manager/java-client-testing"
27+
value: "secret_manager/java-it-service-account"
1728
}
1829

1930
env_vars: {
2031
key: "SECRET_MANAGER_KEYS"
21-
value: "java-client-testing"
32+
value: "java-it-service-account"
2233
}
2334

2435
env_vars: {

.kokoro/presubmit/integration.cfg

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,24 @@ env_vars: {
1111
value: "integration"
1212
}
1313

14+
# TODO: remove this after we've migrated all tests and scripts
15+
env_vars: {
16+
key: "GCLOUD_PROJECT"
17+
value: "gcloud-devel"
18+
}
19+
20+
env_vars: {
21+
key: "GOOGLE_CLOUD_PROJECT"
22+
value: "gcloud-devel"
23+
}
24+
1425
env_vars: {
1526
key: "GOOGLE_APPLICATION_CREDENTIALS"
16-
value: "secret_manager/java-client-testing"
27+
value: "secret_manager/java-it-service-account"
1728
}
1829

1930
env_vars: {
2031
key: "SECRET_MANAGER_KEYS"
21-
value: "java-client-testing"
32+
value: "java-it-service-account"
2233
}
34+

google-cloud-spanner-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>com.google.cloud</groupId>
1010
<artifactId>sdk-platform-java-config</artifactId>
11-
<version>3.45.1</version>
11+
<version>3.46.2</version>
1212
</parent>
1313

1414
<name>Google Cloud Spanner BOM</name>

google-cloud-spanner/src/main/java/com/google/cloud/spanner/Key.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.ArrayList;
3232
import java.util.Collections;
3333
import java.util.List;
34+
import java.util.UUID;
3435
import javax.annotation.Nullable;
3536

3637
/**
@@ -70,6 +71,7 @@ private Key(List<Object> parts) {
7071
* <li>{@link ByteArray} for the {@code BYTES} Cloud Spanner type
7172
* <li>{@link Timestamp} for the {@code TIMESTAMP} Cloud Spanner type
7273
* <li>{@link Date} for the {@code DATE} Cloud Spanner type
74+
* <li>{@link java.util.UUID} for the {@code UUID} Cloud Spanner type
7375
* </ul>
7476
*
7577
* @throws IllegalArgumentException if any member of {@code values} is not a supported type
@@ -178,6 +180,12 @@ public Builder append(@Nullable Date value) {
178180
return this;
179181
}
180182

183+
/** Appends a {@code UUID} value to the key */
184+
public Builder append(@Nullable UUID value) {
185+
buffer.add(value);
186+
return this;
187+
}
188+
181189
/**
182190
* Appends an object following the same conversion rules as {@link Key#of(Object...)}. When
183191
* using the {@code Builder}, most code should prefer using the strongly typed {@code
@@ -206,6 +214,8 @@ public Builder appendObject(@Nullable Object value) {
206214
append((Timestamp) value);
207215
} else if (value instanceof Date) {
208216
append((Date) value);
217+
} else if (value instanceof UUID) {
218+
append((UUID) value);
209219
} else if (value instanceof ProtocolMessageEnum) {
210220
append((ProtocolMessageEnum) value);
211221
} else {
@@ -316,6 +326,8 @@ ListValue toProto() {
316326
builder.addValuesBuilder().setStringValue(part.toString());
317327
} else if (part instanceof Date) {
318328
builder.addValuesBuilder().setStringValue(part.toString());
329+
} else if (part instanceof UUID) {
330+
builder.addValuesBuilder().setStringValue(part.toString());
319331
} else if (part instanceof ProtocolMessageEnum) {
320332
builder
321333
.addValuesBuilder()

google-cloud-spanner/src/test/java/com/google/cloud/spanner/KeyTest.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.google.protobuf.ListValue;
2727
import com.google.protobuf.NullValue;
2828
import java.math.BigDecimal;
29+
import java.util.UUID;
2930
import org.junit.Test;
3031
import org.junit.runner.RunWith;
3132
import org.junit.runners.JUnit4;
@@ -51,6 +52,7 @@ public void of() {
5152
String numeric = "3.141592";
5253
String timestamp = "2015-09-15T00:00:00Z";
5354
String date = "2015-09-15";
55+
String uuid = UUID.randomUUID().toString();
5456
String json = "{\"color\":\"red\",\"value\":\"#f00\"}";
5557
k =
5658
Key.of(
@@ -65,8 +67,9 @@ public void of() {
6567
json,
6668
ByteArray.copyFrom("y"),
6769
Timestamp.parseTimestamp(timestamp),
68-
Date.parseDate(date));
69-
assertThat(k.size()).isEqualTo(12);
70+
Date.parseDate(date),
71+
UUID.fromString(uuid));
72+
assertThat(k.size()).isEqualTo(13);
7073
assertThat(k.getParts())
7174
.containsExactly(
7275
null,
@@ -80,7 +83,8 @@ public void of() {
8083
json,
8184
ByteArray.copyFrom("y"),
8285
Timestamp.parseTimestamp(timestamp),
83-
Date.parseDate(date))
86+
Date.parseDate(date),
87+
UUID.fromString(uuid))
8488
.inOrder();
8589

8690
// Singleton null key.
@@ -94,6 +98,7 @@ public void builder() {
9498
String numeric = "3.141592";
9599
String timestamp = "2015-09-15T00:00:00Z";
96100
String date = "2015-09-15";
101+
String uuid = UUID.randomUUID().toString();
97102
String json = "{\"color\":\"red\",\"value\":\"#f00\"}";
98103
Key k =
99104
Key.newBuilder()
@@ -109,8 +114,9 @@ public void builder() {
109114
.append(ByteArray.copyFrom("y"))
110115
.append(Timestamp.parseTimestamp(timestamp))
111116
.append(Date.parseDate(date))
117+
.append(UUID.fromString(uuid))
112118
.build();
113-
assertThat(k.size()).isEqualTo(12);
119+
assertThat(k.size()).isEqualTo(13);
114120
assertThat(k.getParts())
115121
.containsExactly(
116122
null,
@@ -124,7 +130,8 @@ public void builder() {
124130
json,
125131
ByteArray.copyFrom("y"),
126132
Timestamp.parseTimestamp(timestamp),
127-
Date.parseDate(date))
133+
Date.parseDate(date),
134+
UUID.fromString(uuid))
128135
.inOrder();
129136
}
130137

@@ -153,6 +160,8 @@ public void testToString() {
153160
.isEqualTo("[" + timestamp + "]");
154161
String date = "2015-09-15";
155162
assertThat(Key.of(Date.parseDate(date)).toString()).isEqualTo("[" + date + "]");
163+
String uuid = UUID.randomUUID().toString();
164+
assertThat(Key.of(UUID.fromString(uuid)).toString()).isEqualTo("[" + uuid + "]");
156165
assertThat(Key.of(1, 2, 3).toString()).isEqualTo("[1,2,3]");
157166
}
158167

@@ -173,6 +182,7 @@ public void equalsAndHashCode() {
173182
Key.newBuilder().append((ByteArray) null).build(),
174183
Key.newBuilder().append((Timestamp) null).build(),
175184
Key.newBuilder().append((Date) null).build(),
185+
Key.newBuilder().append((UUID) null).build(),
176186
Key.newBuilder().appendObject(null).build());
177187

178188
tester.addEqualityGroup(Key.of(true), Key.newBuilder().append(true).build());
@@ -197,6 +207,8 @@ public void equalsAndHashCode() {
197207
tester.addEqualityGroup(Key.of(t), Key.newBuilder().append(t).build());
198208
Date d = Date.parseDate("2016-09-15");
199209
tester.addEqualityGroup(Key.of(d), Key.newBuilder().append(d).build());
210+
UUID uuid = UUID.randomUUID();
211+
tester.addEqualityGroup(Key.of(uuid), Key.newBuilder().append(uuid).build());
200212
tester.addEqualityGroup(Key.of("a", 2, null));
201213

202214
tester.testEquals();
@@ -215,13 +227,15 @@ public void serialization() {
215227
reserializeAndAssert(Key.of(ByteArray.copyFrom("xyz")));
216228
reserializeAndAssert(Key.of(Timestamp.parseTimestamp("2015-09-15T00:00:00Z")));
217229
reserializeAndAssert(Key.of(Date.parseDate("2015-09-15")));
230+
reserializeAndAssert(Key.of(UUID.randomUUID()));
218231
reserializeAndAssert(Key.of(1, 2, 3));
219232
}
220233

221234
@Test
222235
public void toProto() {
223236
String timestamp = "2015-09-15T00:00:00Z";
224237
String date = "2015-09-15";
238+
String uuid = UUID.randomUUID().toString();
225239
Key k =
226240
Key.newBuilder()
227241
.append((Boolean) null)
@@ -236,6 +250,7 @@ public void toProto() {
236250
.append(ByteArray.copyFrom("y"))
237251
.append(Timestamp.parseTimestamp(timestamp))
238252
.append(Date.parseDate(date))
253+
.append(UUID.fromString(uuid))
239254
.build();
240255
ListValue.Builder builder = ListValue.newBuilder();
241256
builder.addValuesBuilder().setNullValue(NullValue.NULL_VALUE);
@@ -250,6 +265,7 @@ public void toProto() {
250265
builder.addValuesBuilder().setStringValue("eQ==");
251266
builder.addValuesBuilder().setStringValue(timestamp);
252267
builder.addValuesBuilder().setStringValue(date);
268+
builder.addValuesBuilder().setStringValue(uuid);
253269
assertThat(k.toProto()).isEqualTo(builder.build());
254270
}
255271
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>com.google.cloud</groupId>
1616
<artifactId>sdk-platform-java-config</artifactId>
17-
<version>3.45.1</version>
17+
<version>3.46.2</version>
1818
</parent>
1919

2020
<developers>

0 commit comments

Comments
 (0)