TaiJuWu commented on code in PR #24338:
URL: https://github.com/apache/kafka/pull/24338#discussion_r4660992604
##########
clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/producer/ProducerIntegrationTest.java:
##########
@@ -112,6 +113,34 @@ public void
testTransactionWithAndWithoutSend(ClusterInstance cluster) {
}
}
+ @ClusterTests({
+ @ClusterTest(features = {
+ @ClusterFeature(feature = Feature.TRANSACTION_VERSION, version =
0)}),
+ @ClusterTest(features = {
+ @ClusterFeature(feature = Feature.TRANSACTION_VERSION, version =
1)}),
+ @ClusterTest(features = {
+ @ClusterFeature(feature = Feature.TRANSACTION_VERSION, version =
2)}),
+ })
+ public void testCloseWithEmptyTransaction(ClusterInstance cluster) {
+ Map<String, Object> properties = Map.of(
+ ProducerConfig.TRANSACTIONAL_ID_CONFIG, "foobar",
+ ProducerConfig.CLIENT_ID_CONFIG, "test",
+ ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, "true",
+ ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, "60000");
+ var producer = cluster.producer(properties);
+ try {
+ producer.initTransactions();
+ producer.beginTransaction();
+ } catch (RuntimeException e) {
+ producer.close();
+ throw e;
+ }
+ long start = System.nanoTime();
+ producer.close();
Review Comment:
how about to avoid close producer two times.
```
try (var producer = cluster.producer(properties)) {
producer.initTransactions();
producer.beginTransaction();
long start = System.nanoTime();
producer.close();
long elapsedMs =
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
assertTrue(elapsedMs < 5000, "close() took " + elapsedMs + "
ms with an empty
transaction");
}
```
--
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]