Savonitar commented on code in PR #355:
URL:
https://github.com/apache/flink-connector-kafka/pull/355#discussion_r4701317422
##########
flink-connector-kafka/src/main/java/org/apache/flink/connector/kafka/sink/KafkaWriter.java:
##########
@@ -201,7 +207,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:
If a Kafka send has already failed and `recordSerializer.close()` also
throws, could we still run `checkAsyncException()` so the writer reports both
failures and counts the failed send?
##########
flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/sink/KafkaWriterITCase.java:
##########
@@ -120,6 +124,78 @@ public void
testIncreasingRecordBasedCounters(DeliveryGuarantee guarantee) throw
}
}
+ @ParameterizedTest
+ @EnumSource(
+ value = DeliveryGuarantee.class,
+ names = {"AT_LEAST_ONCE", "EXACTLY_ONCE"})
+ public void
testRecordSerializerIsOpenedAndClosedOnceWithWriter(DeliveryGuarantee guarantee)
+ throws Exception {
+ final LifecycleRecordSerializer serializer = new
LifecycleRecordSerializer(topic, false);
+ final KafkaWriter<Integer> writer =
Review Comment:
nit: Could we use try-with-resources here and keep the final assertions
after the block? That way the writer still closes if the open-count assertion
fails.
--
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]