Browse Source

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 <wangguoz@gmail.com>
pull/3900/merge
Bill Bejeck 6 years ago committed by GitHub
parent
commit
a552a2704e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java

2
clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java

@ -1189,7 +1189,6 @@ public class KafkaProducer<K, V> implements Producer<K, V> { @@ -1189,7 +1189,6 @@ public class KafkaProducer<K, V> implements Producer<K, V> {
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<K, V> implements Producer<K, V> { @@ -1197,6 +1196,7 @@ public class KafkaProducer<K, V> implements Producer<K, V> {
}
throw new KafkaException("Failed to close kafka producer", exception);
}
log.debug("Kafka producer has been closed");
}
private static Map<String, Object> propsToMap(Properties properties) {

Loading…
Cancel
Save