chia7712 commented on code in PR #16344:
URL: https://github.com/apache/kafka/pull/16344#discussion_r2517753553
##########
clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:
##########
@@ -1176,18 +1177,25 @@ private ClusterAndWaitTime waitOnMetadata(String topic,
Integer partition, long
metadata.awaitUpdate(version, remainingWaitMs);
} catch (TimeoutException ex) {
// Rethrow with original maxWaitMs to prevent logging
exception with remainingWaitMs
- throw new TimeoutException(
- String.format("Topic %s not present in metadata after
%d ms.",
- topic, maxWaitMs));
+ final String errorMessage = String.format("Topic %s not
present in metadata after %d ms.",
+ topic, maxWaitMs);
+ if (metadata.getError(topic) != null) {
+ throw new TimeoutException(errorMessage,
metadata.getError(topic).exception());
+ }
+ throw new TimeoutException(errorMessage);
}
cluster = metadata.fetch();
elapsed = time.milliseconds() - nowMs;
if (elapsed >= maxWaitMs) {
- throw new TimeoutException(partitionsCount == null ?
+ final String errorMessage = partitionsCount == null ?
String.format("Topic %s not present in metadata after
%d ms.",
topic, maxWaitMs) :
String.format("Partition %d of topic %s with partition
count %d is not present in metadata after %d ms.",
- partition, topic, partitionsCount, maxWaitMs));
+ partition, topic, partitionsCount, maxWaitMs);
+ if (metadata.getError(topic) != null &&
metadata.getError(topic).exception() instanceof RetriableException) {
Review Comment:
Excuse me, why add the extra error message exclusively for
`RetriableException`? what are the drawbacks if we include the topic exception
every time?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]