[ https://issues.apache.org/jira/browse/KAFKA-5039?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16551055#comment-16551055 ]
ASF GitHub Bot commented on KAFKA-5039: --------------------------------------- ijuma closed pull request #2820: KAFKA-5039: Logging in BlockingChannel and SyncProducer connect URL: https://github.com/apache/kafka/pull/2820 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/core/src/main/scala/kafka/network/BlockingChannel.scala b/core/src/main/scala/kafka/network/BlockingChannel.scala index 0f10577f811..06e39dcd555 100644 --- a/core/src/main/scala/kafka/network/BlockingChannel.scala +++ b/core/src/main/scala/kafka/network/BlockingChannel.scala @@ -82,7 +82,10 @@ class BlockingChannel( val host: String, connectTimeoutMs)) } catch { - case _: Throwable => disconnect() + case e: Throwable => { + debug("Error trying to connect, will disconnect.", e) + disconnect() + } } } } diff --git a/core/src/main/scala/kafka/producer/SyncProducer.scala b/core/src/main/scala/kafka/producer/SyncProducer.scala index f02648f53e4..e82ed44993e 100644 --- a/core/src/main/scala/kafka/producer/SyncProducer.scala +++ b/core/src/main/scala/kafka/producer/SyncProducer.scala @@ -149,7 +149,9 @@ class SyncProducer(val config: SyncProducerConfig) extends Logging { if (!blockingChannel.isConnected && !shutdown) { try { blockingChannel.connect() - info("Connected to " + formatAddress(config.host, config.port) + " for producing") + if (blockingChannel.isConnected) { + info("Connected to " + formatAddress(config.host, config.port) + " for producing") + } } catch { case e: Exception => { disconnect() ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Logging in BlockingChannel and SyncProducer connect > --------------------------------------------------- > > Key: KAFKA-5039 > URL: https://issues.apache.org/jira/browse/KAFKA-5039 > Project: Kafka > Issue Type: Bug > Reporter: Arun Mahadevan > Assignee: Arun Mahadevan > Priority: Minor > > When an exception is thrown in BlockingChannel::connect, the connection is > disconnected but the actual exception is not logged. This later manifests as > ClosedChannelException when trying to send. Also the SyncProducer wrongfully > logs "Connected to host:port for producing" even in case of exceptions. -- This message was sent by Atlassian JIRA (v7.6.3#76005)