chia7712 commented on code in PR #20159:
URL: https://github.com/apache/kafka/pull/20159#discussion_r2386239053
##########
clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:
##########
@@ -1224,11 +1243,18 @@ 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
- final String errorMessage = getErrorMessage(partitionsCount,
topic, partition, maxWaitMs);
- if (metadata.getError(topic) != null) {
- throw new TimeoutException(errorMessage,
metadata.getError(topic).exception());
+ Throwable cause;
+ Errors error = metadata.getError(topic);
+ if (error != null) {
Review Comment:
It would be better to exclude `None`
##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionalRequestResult.java:
##########
@@ -52,11 +54,15 @@ public void await() {
}
public void await(long timeout, TimeUnit unit) {
Review Comment:
Also, `new KafkaException("Unknown reason.")` is a bit odd to me, Could you
please refactor code to avoid such exception?
##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java:
##########
@@ -415,7 +415,9 @@ private long sendProducerData(long now) {
for (ProducerBatch expiredBatch : expiredBatches) {
String errorMessage = "Expiring " + expiredBatch.recordCount + "
record(s) for " + expiredBatch.topicPartition
+ ":" + (now - expiredBatch.createdMs) + " ms has passed since
batch creation";
- failBatch(expiredBatch, new TimeoutException(errorMessage), false);
+ KafkaException potentialCause = new KafkaException(
+ "The broker might be unavailable or responding slowly, or
the CPU might be busy.");
+ failBatch(expiredBatch, new TimeoutException(errorMessage,
potentialCause), false);
Review Comment:
I think the `errorMessage` is sufficient, since it already covers everything
##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionalRequestResult.java:
##########
@@ -52,11 +54,15 @@ public void await() {
}
public void await(long timeout, TimeUnit unit) {
Review Comment:
this method could be inlined to `await()`
--
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]