varkey98 commented on code in PR #355:
URL: 
https://github.com/apache/flink-connector-kafka/pull/355#discussion_r4690183432


##########
flink-connector-kafka/src/main/java/org/apache/flink/connector/kafka/sink/KafkaWriter.java:
##########
@@ -201,7 +201,7 @@ public List<KafkaWriterState> snapshotState(long 
checkpointId) throws IOExceptio
     public void close() throws Exception {
         markClosed();
         LOG.debug("Closing writer with {}", currentProducer);
-        closeAll(currentProducer);
+        closeAll(currentProducer, recordSerializer::close);

Review Comment:
   Thanks, dropped it. Now the open is done in the initialize and the 
KafkaSinkWriter.close handles it. Since `ExactlyOnceKafkaSinkWriter` also calls 
`super.close()`, that's inherited as well.



##########
flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/sink/KafkaWriterITCase.java:
##########
@@ -120,6 +122,27 @@ public void 
testIncreasingRecordBasedCounters(DeliveryGuarantee guarantee) throw
         }
     }
 
+    @ParameterizedTest
+    @EnumSource(
+            value = DeliveryGuarantee.class,
+            names = {"AT_LEAST_ONCE", "EXACTLY_ONCE"})
+    public void testRecordSerializerIsClosedWithWriter(DeliveryGuarantee 
guarantee)
+            throws Exception {
+        final AtomicInteger closeCalls = new AtomicInteger();
+        final KafkaRecordSerializationSchema<Integer> delegate = new 
IntegerRecordSerializer(topic);
+        final KafkaWriter<Integer> writer =
+                createWriter(
+                        builder ->
+                                builder.setDeliveryGuarantee(guarantee)
+                                        .setRecordSerializer(
+                                                new 
ClosingRecordSerializer(delegate, closeCalls)),

Review Comment:
   Thanks, fixed it



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