Skip to content

Commit 4c260a8

Browse files
committed
Use BigInteger to generate the 64-bit integer
1 parent 4fea875 commit 4c260a8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.google.api.core.InternalApi;
2020
import com.google.common.annotations.VisibleForTesting;
21+
import java.math.BigInteger;
2122
import java.security.SecureRandom;
2223
import java.util.Objects;
2324

@@ -48,7 +49,8 @@ public static XGoogSpannerRequestId of(
4849

4950
private static String generateRandProcessId() {
5051
// Expecting to use 64-bits of randomness to avoid clashes.
51-
return String.format("%016x", new SecureRandom().nextInt(64));
52+
BigInteger bigInt = new BigInteger(64, new SecureRandom());
53+
return String.format("%016x", bigInt);
5254
}
5355

5456
@Override

0 commit comments

Comments
 (0)