ijuma commented on code in PR #12365:
URL: https://github.com/apache/kafka/pull/12365#discussion_r924206144


##########
clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:
##########
@@ -1491,20 +1495,25 @@ public void setPartition(int partition) {
 
             if (log.isTraceEnabled()) {
                 // Log the message here, because we don't know the partition 
before that.
-                log.trace("Attempting to append record {} with callback {} to 
topic {} partition {}", record, userCallback, record.topic(), partition);
+                log.trace("Attempting to append record {} with callback {} to 
topic {} partition {}", record, userCallback, topic, partition);
             }
+
+            // Reset record to null here so that it doesn't have to be alive 
as long as the batch is.
+            record = null;

Review Comment:
   I find that the code complexity to achieve this trace logging is a bit high. 
I have some ideas on how to improve it, but we can leave that for latter. A 
simple suggestion for now would be to change `setPartition` to 
`onPartitionAssigned` or something like that. This would indicate a general 
callback that can do anything once the partition is known.



-- 
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-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to