kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject kafka git commit: MINOR: Ensure that selection key is cancelled on close
Date Wed, 11 May 2016 13:04:16 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 3e89d2bc5 -> e20eba958


MINOR: Ensure that selection key is cancelled on close

Author: Rajini Sivaram <rajinisivaram@googlemail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #1368 from rajinisivaram/minor-channelclose


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/e20eba95
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/e20eba95
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/e20eba95

Branch: refs/heads/trunk
Commit: e20eba958d8de29cb4e3b6feea37ac3a1e1ab4f9
Parents: 3e89d2b
Author: Rajini Sivaram <rajinisivaram@googlemail.com>
Authored: Wed May 11 13:05:58 2016 +0100
Committer: Ismael Juma <ismael@juma.me.uk>
Committed: Wed May 11 13:05:58 2016 +0100

----------------------------------------------------------------------
 .../kafka/common/network/PlaintextTransportLayer.java | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/e20eba95/clients/src/main/java/org/apache/kafka/common/network/PlaintextTransportLayer.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/common/network/PlaintextTransportLayer.java
b/clients/src/main/java/org/apache/kafka/common/network/PlaintextTransportLayer.java
index 3db4345..1135359 100644
--- a/clients/src/main/java/org/apache/kafka/common/network/PlaintextTransportLayer.java
+++ b/clients/src/main/java/org/apache/kafka/common/network/PlaintextTransportLayer.java
@@ -30,11 +30,8 @@ import java.nio.channels.SelectionKey;
 import java.security.Principal;
 
 import org.apache.kafka.common.security.auth.KafkaPrincipal;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class PlaintextTransportLayer implements TransportLayer {
-    private static final Logger log = LoggerFactory.getLogger(PlaintextTransportLayer.class);
     private final SelectionKey key;
     private final SocketChannel socketChannel;
     private final Principal principal = KafkaPrincipal.ANONYMOUS;
@@ -84,10 +81,13 @@ public class PlaintextTransportLayer implements TransportLayer {
      */
     @Override
     public void close() throws IOException {
-        socketChannel.socket().close();
-        socketChannel.close();
-        key.attach(null);
-        key.cancel();
+        try {
+            socketChannel.socket().close();
+            socketChannel.close();
+        } finally {
+            key.attach(null);
+            key.cancel();
+        }
     }
 
     /**


Mime
View raw message