chia7712 commented on a change in pull request #9817: URL: https://github.com/apache/kafka/pull/9817#discussion_r552851362
########## File path: clients/src/main/java/org/apache/kafka/clients/producer/internals/BufferPool.java ########## @@ -212,10 +212,15 @@ protected void recordWaitTime(long timeNs) { /** * Allocate a buffer. If buffer allocation fails (e.g. because of OOM) then return the size count back to * available memory and signal the next waiter if it exists. + * + * if producer is closing, will throw close-exception */ private ByteBuffer safeAllocateByteBuffer(int size) { boolean error = true; try { + if (this.closed) { Review comment: It is not holding the lock so this pool can be closed anytime. How we know the "best" place to check the close flag? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org