From 9c7064778935aeda91391a4eb8753af0a590b9d6 Mon Sep 17 00:00:00 2001 From: Manikumar Reddy Date: Wed, 30 Aug 2017 16:52:38 +0530 Subject: [PATCH] KAFKA-3131: enable error level for SSLException logs --- .../apache/kafka/common/network/Selector.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/clients/src/main/java/org/apache/kafka/common/network/Selector.java b/clients/src/main/java/org/apache/kafka/common/network/Selector.java index 7977879d46191..4f35db38a1266 100644 --- a/clients/src/main/java/org/apache/kafka/common/network/Selector.java +++ b/clients/src/main/java/org/apache/kafka/common/network/Selector.java @@ -53,6 +53,8 @@ import org.apache.kafka.common.utils.Time; import org.slf4j.Logger; +import javax.net.ssl.SSLException; + /** * A nioSelector interface for doing non-blocking multi-connection network I/O. *

@@ -483,10 +485,7 @@ void pollSelectionKeys(Set selectionKeys, } catch (Exception e) { String desc = channel.socketDescription(); - if (e instanceof IOException) - log.debug("Connection with {} disconnected", desc, e); - else - log.warn("Unexpected error from {}; closing connection", desc, e); + logException(e, desc); close(channel, true); } finally { maybeRecordTimePerConnection(channel, channelStartTimeNanos); @@ -494,6 +493,15 @@ void pollSelectionKeys(Set selectionKeys, } } + private void logException(Exception e, String desc) { + if (e instanceof SSLException) + log.error("SSL connection error from {}; closing connection", desc, e); + else if (e instanceof IOException) + log.debug("Connection with {} disconnected", desc, e); + else + log.warn("Unexpected error from {}; closing connection", desc, e); + } + private Collection determineHandlingOrder(Set selectionKeys) { //it is possible that the iteration order over selectionKeys is the same every invocation. //this may cause starvation of reads when memory is low. to address this we shuffle the keys if memory is low.