Skip to content

Commit 606e272

Browse files
Merge branch 'main' into main
2 parents 90d29b1 + c12968a commit 606e272

File tree

10 files changed

+163
-7
lines changed

10 files changed

+163
-7
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.42.0
20+
uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.43.0
2121
with:
2222
bom-path: google-cloud-spanner-bom/pom.xml

.kokoro/presubmit/graalvm-native-17.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Configure the docker image for kokoro-trampoline.
44
env_vars: {
55
key: "TRAMPOLINE_IMAGE"
6-
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.42.0"
6+
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.43.0"
77
}
88

99
env_vars: {

.kokoro/presubmit/graalvm-native.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Configure the docker image for kokoro-trampoline.
44
env_vars: {
55
key: "TRAMPOLINE_IMAGE"
6-
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.42.0"
6+
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.43.0"
77
}
88

99
env_vars: {

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.42.0</version>
11+
<version>3.43.0</version>
1212
</parent>
1313

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

google-cloud-spanner-executor/pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
<groupId>com.google.cloud.opentelemetry</groupId>
4747
<artifactId>exporter-trace</artifactId>
4848
<version>0.33.0</version>
49+
<exclusions>
50+
<exclusion>
51+
<groupId>io.opentelemetry.semconv</groupId>
52+
<artifactId>opentelemetry-semconv</artifactId>
53+
</exclusion>
54+
</exclusions>
55+
</dependency>
56+
<dependency>
57+
<groupId>io.opentelemetry.semconv</groupId>
58+
<artifactId>opentelemetry-semconv</artifactId>
4959
</dependency>
5060
<dependency>
5161
<groupId>com.google.cloud</groupId>
@@ -266,7 +276,7 @@
266276
<groupId>org.apache.maven.plugins</groupId>
267277
<artifactId>maven-dependency-plugin</artifactId>
268278
<configuration>
269-
<ignoredDependencies> com.google.api:gax,org.apache.maven.surefire:surefire-junit4 </ignoredDependencies>
279+
<ignoredDependencies> com.google.api:gax,org.apache.maven.surefire:surefire-junit4,io.opentelemetry.semconv:opentelemetry-semconv </ignoredDependencies>
270280
</configuration>
271281
</plugin>
272282
</plugins>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.spanner;
18+
19+
import com.google.api.core.InternalApi;
20+
import com.google.common.annotations.VisibleForTesting;
21+
import java.math.BigInteger;
22+
import java.security.SecureRandom;
23+
import java.util.Objects;
24+
25+
@InternalApi
26+
public class XGoogSpannerRequestId {
27+
// 1. Generate the random process Id singleton.
28+
@VisibleForTesting
29+
static final String RAND_PROCESS_ID = XGoogSpannerRequestId.generateRandProcessId();
30+
31+
@VisibleForTesting
32+
static final long VERSION = 1; // The version of the specification being implemented.
33+
34+
private final long nthClientId;
35+
private final long nthChannelId;
36+
private final long nthRequest;
37+
private long attempt;
38+
39+
XGoogSpannerRequestId(long nthClientId, long nthChannelId, long nthRequest, long attempt) {
40+
this.nthClientId = nthClientId;
41+
this.nthChannelId = nthChannelId;
42+
this.nthRequest = nthRequest;
43+
this.attempt = attempt;
44+
}
45+
46+
public static XGoogSpannerRequestId of(
47+
long nthClientId, long nthChannelId, long nthRequest, long attempt) {
48+
return new XGoogSpannerRequestId(nthClientId, nthChannelId, nthRequest, attempt);
49+
}
50+
51+
private static String generateRandProcessId() {
52+
// Expecting to use 64-bits of randomness to avoid clashes.
53+
BigInteger bigInt = new BigInteger(64, new SecureRandom());
54+
return String.format("%016x", bigInt);
55+
}
56+
57+
@Override
58+
public String toString() {
59+
return String.format(
60+
"%d.%s.%d.%d.%d.%d",
61+
XGoogSpannerRequestId.VERSION,
62+
XGoogSpannerRequestId.RAND_PROCESS_ID,
63+
this.nthClientId,
64+
this.nthChannelId,
65+
this.nthRequest,
66+
this.attempt);
67+
}
68+
69+
@Override
70+
public boolean equals(Object other) {
71+
// instanceof for a null object returns false.
72+
if (!(other instanceof XGoogSpannerRequestId)) {
73+
return false;
74+
}
75+
76+
XGoogSpannerRequestId otherReqId = (XGoogSpannerRequestId) (other);
77+
78+
return Objects.equals(this.nthClientId, otherReqId.nthClientId)
79+
&& Objects.equals(this.nthChannelId, otherReqId.nthChannelId)
80+
&& Objects.equals(this.nthRequest, otherReqId.nthRequest)
81+
&& Objects.equals(this.attempt, otherReqId.attempt);
82+
}
83+
84+
@Override
85+
public int hashCode() {
86+
return Objects.hash(this.nthClientId, this.nthChannelId, this.nthRequest, this.attempt);
87+
}
88+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Args = --initialize-at-build-time=com.google.cloud.spanner.IntegrationTestEnv,\
22
org.junit.experimental.categories.CategoryValidator,\
3-
org.junit.validator.AnnotationValidator \
3+
org.junit.validator.AnnotationValidator,\
4+
java.lang.annotation.Annotation \
45
--features=com.google.cloud.spanner.nativeimage.SpannerFeature
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.spanner;
18+
19+
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertNotEquals;
21+
import static org.junit.Assert.assertTrue;
22+
23+
import java.util.regex.Matcher;
24+
import java.util.regex.Pattern;
25+
import org.junit.Test;
26+
import org.junit.runner.RunWith;
27+
import org.junit.runners.JUnit4;
28+
29+
@RunWith(JUnit4.class)
30+
public class XGoogSpannerRequestIdTest {
31+
private static final Pattern REGEX_RAND_PROCESS_ID =
32+
Pattern.compile("1.([0-9a-z]{16})(\\.\\d+){3}\\.(\\d+)$");
33+
34+
@Test
35+
public void testEquals() {
36+
XGoogSpannerRequestId reqID1 = XGoogSpannerRequestId.of(1, 1, 1, 1);
37+
XGoogSpannerRequestId reqID2 = XGoogSpannerRequestId.of(1, 1, 1, 1);
38+
assertEquals(reqID1, reqID2);
39+
assertEquals(reqID1, reqID1);
40+
assertEquals(reqID2, reqID2);
41+
42+
XGoogSpannerRequestId reqID3 = XGoogSpannerRequestId.of(1, 1, 1, 2);
43+
assertNotEquals(reqID1, reqID3);
44+
assertNotEquals(reqID3, reqID1);
45+
assertEquals(reqID3, reqID3);
46+
}
47+
48+
@Test
49+
public void testEnsureHexadecimalFormatForRandProcessID() {
50+
String str = XGoogSpannerRequestId.of(1, 2, 3, 4).toString();
51+
Matcher m = XGoogSpannerRequestIdTest.REGEX_RAND_PROCESS_ID.matcher(str);
52+
assertTrue(m.matches());
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Args=--initialize-at-build-time=org.junit.runner.RunWith \
2+
--initialize-at-build-time=org.junit.experimental.categories.Category \
3+
--initialize-at-build-time=org.junit.runners.model.FrameworkField

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.42.0</version>
17+
<version>3.43.0</version>
1818
</parent>
1919

2020
<developers>

0 commit comments

Comments
 (0)