chia7712 commented on code in PR #22442:
URL: https://github.com/apache/kafka/pull/22442#discussion_r3374995481


##########
clients/src/main/java/org/apache/kafka/common/Uuid.java:
##########
@@ -71,9 +71,24 @@ private static Uuid unsafeRandomUuid() {
     /**
      * Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
      * <p>
-     * This will not generate a UUID equal to 0, 1, or one whose string 
representation contains a dash ("-").
+     * This will not generate a UUID equal to 0, 1, or one whose string 
representation starts with a dash ("-").
      */
     public static Uuid randomUuid() {
+        Uuid uuid = unsafeRandomUuid();
+        while (RESERVED.contains(uuid) || uuid.toString().startsWith("-")) {
+            uuid = unsafeRandomUuid();
+        }
+        return uuid;
+    }
+
+    /**
+     * Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
+     * <p>
+     * This will not generate a UUID equal to 0, 1, or one whose string 
representation contains a dash ("-").
+     * Note that this will result in 30% rejected UUIDs, and so should not be 
used in performance sensitive
+     * code paths.
+     */
+    public static Uuid randomUuidNoDashes() {

Review Comment:
   I guess it needs a KIP?



-- 
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]

Reply via email to