chia7712 commented on a change in pull request #9520: URL: https://github.com/apache/kafka/pull/9520#discussion_r549567477
########## File path: clients/src/test/java/org/apache/kafka/clients/producer/internals/TransactionManagerTest.java ########## @@ -444,34 +444,30 @@ public void testAddPartitionToTransactionRetainsRetryBackoffWhenPartitionsAlread assertEquals(DEFAULT_RETRY_BACKOFF_MS, handler.retryBackoffMs()); } - @Test(expected = IllegalStateException.class) + @Test public void testMaybeAddPartitionToTransactionBeforeInitTransactions() { - transactionManager.failIfNotReadyForSend(); - transactionManager.maybeAddPartitionToTransaction(new TopicPartition("foo", 0)); + assertThrows(IllegalStateException.class, () -> transactionManager.failIfNotReadyForSend()); } - @Test(expected = IllegalStateException.class) + @Test public void testMaybeAddPartitionToTransactionBeforeBeginTransaction() { doInitTransactions(); - transactionManager.failIfNotReadyForSend(); - transactionManager.maybeAddPartitionToTransaction(new TopicPartition("foo", 0)); + assertThrows(IllegalStateException.class, () -> transactionManager.failIfNotReadyForSend()); } - @Test(expected = KafkaException.class) + @Test public void testMaybeAddPartitionToTransactionAfterAbortableError() { doInitTransactions(); transactionManager.beginTransaction(); transactionManager.transitionToAbortableError(new KafkaException()); - transactionManager.failIfNotReadyForSend(); - transactionManager.maybeAddPartitionToTransaction(new TopicPartition("foo", 0)); + assertThrows(KafkaException.class, () -> transactionManager.failIfNotReadyForSend()); } - @Test(expected = KafkaException.class) + @Test public void testMaybeAddPartitionToTransactionAfterFatalError() { doInitTransactions(); transactionManager.transitionToFatalError(new KafkaException()); - transactionManager.failIfNotReadyForSend(); - transactionManager.maybeAddPartitionToTransaction(new TopicPartition("foo", 0)); + assertThrows(KafkaException.class, () -> transactionManager.failIfNotReadyForSend()); Review comment: https://github.com/apache/kafka/commit/717c55be971df862c55f55d245b9997f1d6f998c moved the check of state out of ```maybeAddPartitionToTransaction``` and it added ```failIfNotReadyForSend``` to all test cases to make them throw exception. I will update the test cases name to avoid confusion. ---------------------------------------------------------------- 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