kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsiva...@apache.org
Subject [kafka] branch trunk updated: KAFKA-6716: Should close the `discardChannel` in MockSelector#completeSend (#4783)
Date Wed, 28 Mar 2018 14:03:45 GMT
This is an automated email from the ASF dual-hosted git repository.

rsivaram pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 5d5a2ce  KAFKA-6716: Should close the `discardChannel` in MockSelector#completeSend
(#4783)
5d5a2ce is described below

commit 5d5a2ce4bba4b42b3652d0126d1d2dab979a3e07
Author: huxi <huxi_2b@hotmail.com>
AuthorDate: Wed Mar 28 22:03:39 2018 +0800

    KAFKA-6716: Should close the `discardChannel` in MockSelector#completeSend (#4783)
---
 clients/src/test/java/org/apache/kafka/test/MockSelector.java | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clients/src/test/java/org/apache/kafka/test/MockSelector.java b/clients/src/test/java/org/apache/kafka/test/MockSelector.java
index bd27d5c..200d511 100644
--- a/clients/src/test/java/org/apache/kafka/test/MockSelector.java
+++ b/clients/src/test/java/org/apache/kafka/test/MockSelector.java
@@ -124,11 +124,12 @@ public class MockSelector implements Selectable {
 
     private void completeSend(Send send) throws IOException {
         // Consume the send so that we will be able to send more requests to the destination
-        ByteBufferChannel discardChannel = new ByteBufferChannel(send.size());
-        while (!send.completed()) {
-            send.writeTo(discardChannel);
+        try (ByteBufferChannel discardChannel = new ByteBufferChannel(send.size())) {
+            while (!send.completed()) {
+                send.writeTo(discardChannel);
+            }
+            completedSends.add(send);
         }
-        completedSends.add(send);
     }
 
     private void completeDelayedReceives() {

-- 
To stop receiving notification emails like this one, please contact
rsivaram@apache.org.

Mime
View raw message