FrankYang0529 commented on code in PR #20780:
URL: https://github.com/apache/kafka/pull/20780#discussion_r2469378305


##########
coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java:
##########
@@ -220,8 +226,10 @@ public CoordinatorRuntime<S, U> build() {
                 throw new IllegalArgumentException("Serializer must be set.");
             if (compression == null)
                 compression = Compression.NONE;
-            if (appendLingerMs < 0)
-                throw new IllegalArgumentException("AppendLinger must be >= 
0");
+            if (appendLingerMs == null)
+                appendLingerMs = OptionalInt.empty();
+            if (appendLingerMs.isPresent() && appendLingerMs.getAsInt() < -1)
+                throw new IllegalArgumentException("AppendLinger must be empty 
or >= 0");

Review Comment:
   If the `appendLingerMs` is `-1`, it will be input as `OptionalInt.empty()`. 
How about checking the value is >= 0 here?



##########
coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java:
##########
@@ -220,8 +226,10 @@ public CoordinatorRuntime<S, U> build() {
                 throw new IllegalArgumentException("Serializer must be set.");
             if (compression == null)
                 compression = Compression.NONE;
-            if (appendLingerMs < 0)
-                throw new IllegalArgumentException("AppendLinger must be >= 
0");
+            if (appendLingerMs == null)
+                appendLingerMs = OptionalInt.empty();

Review Comment:
   From the production code, the `appendLingerMs` input cannot be null. How 
about we set a default value `OptionalInt.empty()` to `appendLingerMs` and 
remove `appendLingerMs == null` check?



##########
coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java:
##########
@@ -186,6 +186,11 @@ public Builder<S, U> withCompression(Compression 
compression) {
         }
 
         public Builder<S, U> withAppendLingerMs(int appendLingerMs) {
+            this.appendLingerMs = OptionalInt.of(appendLingerMs);
+            return this;
+        }

Review Comment:
   From the references, this function is only used by test code. Should we 
remove it and update test cases to use `OptionalInt` one?



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