From a552a2704e36b6db0a6295370d4e190ff212d5d1 Mon Sep 17 00:00:00 2001 From: Bill Bejeck Date: Mon, 22 Apr 2019 18:59:00 -0400 Subject: [PATCH] MINOR: Move log statement stating producer closed after possible exception (#6606) In the KafkaProducer#close method we have a debug log statement Kafka producer has been closed then a few lines later a KafkaException can occur. This could be confusing to users, so this PR simply moves the log statement to after the possible exception to avoid confusing information in the logs. Reviewers: Guozhang Wang --- .../java/org/apache/kafka/clients/producer/KafkaProducer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java b/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java index e9d2626166c..83a4d5113b2 100644 --- a/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java +++ b/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java @@ -1189,7 +1189,6 @@ public class KafkaProducer implements Producer { ClientUtils.closeQuietly(valueSerializer, "producer valueSerializer", firstException); ClientUtils.closeQuietly(partitioner, "producer partitioner", firstException); AppInfoParser.unregisterAppInfo(JMX_PREFIX, clientId, metrics); - log.debug("Kafka producer has been closed"); Throwable exception = firstException.get(); if (exception != null && !swallowException) { if (exception instanceof InterruptException) { @@ -1197,6 +1196,7 @@ public class KafkaProducer implements Producer { } throw new KafkaException("Failed to close kafka producer", exception); } + log.debug("Kafka producer has been closed"); } private static Map propsToMap(Properties properties) {