You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/04/18 23:19:14 UTC
[GitHub] [kafka] philipnee commented on a diff in pull request #11689: Fixed documentation and handles null topicPartition for KAFKA-12841
philipnee commented on code in PR #11689:
URL: https://github.com/apache/kafka/pull/11689#discussion_r852477525
##########
clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:
##########
@@ -995,8 +995,17 @@ private Future<RecordMetadata> doSend(ProducerRecord<K, V> record, Callback call
// for other exceptions throw directly
} catch (ApiException e) {
log.debug("Exception occurred during message send:", e);
- if (callback != null)
- callback.onCompletion(null, e);
+ // producer callback will make sure to call both 'callback' and interceptor callback
+ if (tp == null) {
+ // set topicPartition to -1 when null
+ tp = ProducerInterceptors.extractTopicPartition(record);
+ }
+
+ Callback interceptCallback = new InterceptorCallback<>(callback, this.interceptors, tp);
+
+ // The onCompletion callback does expect a non-null metadata, but one will be created inside
+ // the interceptor's onCompletion implementation before the user's callback is invoked.
+ interceptCallback.onCompletion(null, e);
Review Comment:
Hey @junrao - thanks for catching this. Created a PR to address this bug: https://github.com/apache/kafka/pull/12064
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org