Skip to content

Commit c084579

Browse files
committed
RandProcessId MUST be 64-bits and not 32-bits
1 parent c80a418 commit c084579

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public static XGoogSpannerRequestId of(
4747
}
4848

4949
private static String generateRandProcessId() {
50-
return String.format("%08x", new SecureRandom().nextInt());
50+
// Expecting to use 64-bits of randomness to avoid clashes.
51+
return String.format("%016x", new SecureRandom().nextInt(64));
5152
}
5253

5354
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
@RunWith(JUnit4.class)
3030
public class XGoogSpannerRequestIdTest {
3131
private static final Pattern REGEX_RAND_PROCESS_ID =
32-
Pattern.compile("1.([0-9a-z]{8})(\\.\\d+){3}\\.(\\d+)$");
32+
Pattern.compile("1.([0-9a-z]{16})(\\.\\d+){3}\\.(\\d+)$");
3333

3434
@Test
3535
public void testEquals() {

0 commit comments

Comments
 (0)