zhaohaidao commented on a change in pull request #9311:
URL: https://github.com/apache/kafka/pull/9311#discussion_r502917518



##########
File path: core/src/test/scala/integration/kafka/api/TransactionsTest.scala
##########
@@ -580,6 +580,52 @@ class TransactionsTest extends KafkaServerTestHarness {
     assertTrue(transactionalRecords.isEmpty)
   }
 
+  @Test
+  def testProducerUsableAfterTxnTimeOutAbortExcetion(): Unit = {
+    val producer = createTransactionalProducer("expiringProducer", 
transactionTimeoutMs = 100)
+
+    producer.initTransactions()
+    producer.beginTransaction()
+
+    // The first message and hence the first AddPartitions request should be 
successfully sent.
+    val firstMessageResult = 
producer.send(TestUtils.producerRecordWithExpectedTransactionStatus(topic1, 
null, "1", "1", willBeCommitted = false)).get()
+    assertTrue(firstMessageResult.hasOffset)
+
+    // Wait for the expiration cycle to kick in.
+    Thread.sleep(600)
+
+    try {
+      // Now that the transaction has expired, the second send should fail 
with a ProducerFencedException.
+      producer.commitTransaction()
+      fail("should have raised a TransactionTimeOutException since the 
transaction has expired")
+    } catch {
+      case _: TransactionTimeoutException =>
+      case e: ExecutionException =>

Review comment:
       This wrap action refers to case testFencingOnAddPartitions, however it 
doesn’t seem that we need 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.

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


Reply via email to