divijvaidya commented on code in PR #12228:
URL: https://github.com/apache/kafka/pull/12228#discussion_r900273174


##########
clients/src/main/java/org/apache/kafka/common/network/Selector.java:
##########
@@ -809,6 +810,13 @@ private void maybeCloseOldestConnection(long 
currentTimeNanos) {
      * poll().
      */
     public void clearCompletedReceives() {
+        this.completedReceives.values().forEach(networkReceive -> {
+            try {
+                networkReceive.close();

Review Comment:
   I don't have a good idea on how to assert in the tests that the 
`NetworkReceive` objects are being closed. I have considered the following:
   1. Using `GarbageCollectedMemoryPool` which could have hinted towards a 
memory leak but it doesn't work.
   2. Assert that the NetworkReceive.Close() is being called in the flow but we 
would need to Spy the objects in the test which is difficult to do here.
   
   I am going to try again on Monday to see if I can figure something out but 
meanwhile, do you have any suggestions here on how can I add a test to validate 
the leak?



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to