dnadolny commented on code in PR #21065:
URL: https://github.com/apache/kafka/pull/21065#discussion_r2662691555


##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/BufferPool.java:
##########
@@ -274,6 +274,17 @@ public void deallocate(ByteBuffer buffer, int size) {
         }
     }
 
+    /**
+     * buffer is passed in only for use in tests
+     */
+    public void deallocateWithoutReuse(ByteBuffer buffer, int size) {
+        // We pass in a fresh buffer to be deallocated (added back to the pool 
if it is a poolable size)
+        // This is slightly inefficient if it's not a poolable size, but those 
tend to be small and
+        // this code is not hit often anyway
+        // This is useful if we're not 100% sure the buffer is not in use, 
which happens in some error cases
+        deallocate(ByteBuffer.allocate(size));

Review Comment:
   Got it now, in retrospect your explanation is clear but I wasn't familiar 
enough with the code to use it (I didn't realize completeBatch (or the other 
path of failBatch) will always be called for an in-flight batch that we already 
call failBatch on).



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