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 3db4345c14f01..1135359f8d196 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.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 boolean isConnected() { */ @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(); + } } /**