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) {