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


##########
clients/src/main/java/org/apache/kafka/common/utils/BufferSupplier.java:
##########
@@ -30,6 +31,7 @@
  * iterating over the records in the batch.
  */
 public abstract class BufferSupplier implements AutoCloseable {
+    protected AtomicLong cachedSize = new AtomicLong();

Review Comment:
   Could you please add `final` declaration?



##########
clients/src/main/java/org/apache/kafka/common/utils/BufferSupplier.java:
##########
@@ -58,6 +63,11 @@ public static BufferSupplier create() {
      */
     public abstract void release(ByteBuffer buffer);
 
+    /**
+     * Return total size in bytes of cached buffers.
+     */
+    public abstract long size();

Review Comment:
   Because all subclasses share the same `size()` implementation, it would be 
better to streamline it as follows
   ```java
       public long size() {
           return cachedSize.get();
       }
   ```



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