kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject kafka git commit: KAFKA-3691; Confusing logging during metadata update timeout
Date Thu, 16 Jun 2016 22:30:19 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk f62db5dd8 -> 47f5ae9e9


KAFKA-3691; Confusing logging during metadata update timeout

Author: Grant Henke <granthenke@gmail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #1509 from granthenke/timeout-logging


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/47f5ae9e
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/47f5ae9e
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/47f5ae9e

Branch: refs/heads/trunk
Commit: 47f5ae9e9c902e18fc0f7f153da945de2839c3e2
Parents: f62db5d
Author: Grant Henke <granthenke@gmail.com>
Authored: Fri Jun 17 00:12:53 2016 +0200
Committer: Ismael Juma <ismael@juma.me.uk>
Committed: Fri Jun 17 00:12:53 2016 +0200

----------------------------------------------------------------------
 .../java/org/apache/kafka/clients/producer/KafkaProducer.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/47f5ae9e/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java
----------------------------------------------------------------------
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 a1bdb42..a61ee93 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
@@ -522,7 +522,12 @@ public class KafkaProducer<K, V> implements Producer<K, V>
{
             log.trace("Requesting metadata update for topic {}.", topic);
             int version = metadata.requestUpdate();
             sender.wakeup();
-            metadata.awaitUpdate(version, remainingWaitMs);
+            try {
+                metadata.awaitUpdate(version, remainingWaitMs);
+            } catch (TimeoutException ex) {
+                // Rethrow with original maxWaitMs to prevent logging exception with remainingWaitMs
+                throw new TimeoutException("Failed to update metadata after " + maxWaitMs
+ " ms.");
+            }
             long elapsed = time.milliseconds() - begin;
             if (elapsed >= maxWaitMs)
                 throw new TimeoutException("Failed to update metadata after " + maxWaitMs
+ " ms.");


Mime
View raw message