fapaul commented on code in PR #159:
URL: 
https://github.com/apache/flink-connector-kafka/pull/159#discussion_r2021104189


##########
flink-connector-kafka/src/main/java/org/apache/flink/connector/kafka/sink/internal/ProducerPoolImpl.java:
##########
@@ -131,26 +131,33 @@ public void recycleByTransactionId(String 
transactionalId) {
         if (!earlierTransactions.isEmpty()) {
             for (String id : earlierTransactions.values()) {
                 ProducerEntry entry = producerByTransactionalId.remove(id);
-                recycleProducer(entry.getProducer());
+                recycleProducer(entry.getProducer(), false);
             }
             earlierTransactions.clear();
         }
     }
 
     @Override
     public void recycle(FlinkKafkaInternalProducer<byte[], byte[]> producer) {
-        recycleProducer(producer);
+        recycleProducer(producer, true);
         ProducerEntry producerEntry =
                 
producerByTransactionalId.remove(producer.getTransactionalId());
         
transactionalIdsByCheckpoint.remove(producerEntry.getCheckpointedTransaction());
     }
 
-    private void recycleProducer(@Nullable FlinkKafkaInternalProducer<byte[], 
byte[]> producer) {
+    private void recycleProducer(

Review Comment:
   My idea would be to add a simple check to `recycleByTransactionId` that 
`recycleProducer` is only invoked if `sucess` is true if false we close the 
producer. 
   
   Afaict `recyleProducer` with success false is only called from 
`recycleByTransactionId` so the code path is only hit in a single scenario. 
   
   This way we should be able to remove the parameter from `recyleProducer`.



-- 
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]

Reply via email to