squah-confluent commented on code in PR #21313:
URL: https://github.com/apache/kafka/pull/21313#discussion_r2696663988
##########
clients/src/main/java/org/apache/kafka/common/Uuid.java:
##########
@@ -70,12 +70,12 @@ private static Uuid unsafeRandomUuid() {
/**
* Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
- *
- * This will not generate a UUID equal to 0, 1, or one whose string
representation starts with a dash ("-")
+ * <p>
+ * This will not generate a UUID equal to 0, 1, or one whose string
representation contains a dash ("-").
*/
public static Uuid randomUuid() {
Uuid uuid = unsafeRandomUuid();
- while (RESERVED.contains(uuid) || uuid.toString().startsWith("-")) {
+ while (RESERVED.contains(uuid) || uuid.toString().contains("-")) {
Review Comment:
Note that the probability of rejecting a generated uuid rises from 1.56% (=
1/64) to 30.5% (= 1 - (63/64)**19 * 15/16, taking into account fixed bits in
version 4 uuids). The new p99 number of rejections is ~3.88 which I think is
not too bad.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]