huxihx commented on a change in pull request #9081:
URL: https://github.com/apache/kafka/pull/9081#discussion_r460609876
##########
File path: core/src/test/scala/integration/kafka/api/TransactionsTest.scala
##########
@@ -406,6 +406,26 @@ class TransactionsTest extends KafkaServerTestHarness {
TestUtils.waitUntilTrue(() =>
offsetAndMetadata.equals(consumer.committed(Set(tp).asJava).get(tp)), "cannot
read committed offset")
}
+ @Test(expected = classOf[TimeoutException])
+ def testSendOffsetsToTransactionTimeout(): Unit = {
+ val producer = createTransactionalProducer("transactionProducer",
maxBlockMs = 1000)
+ producer.initTransactions()
+ producer.beginTransaction()
+ producer.send(new ProducerRecord[Array[Byte], Array[Byte]](topic1,
"foo".getBytes, "bar".getBytes))
+
+ for (i <- 0 until servers.size)
+ killBroker(i)
+
+ val offsets = new mutable.HashMap[TopicPartition,
OffsetAndMetadata]().asJava
+ offsets.put(new TopicPartition(topic1, 0), new OffsetAndMetadata(0))
+ try {
+ producer.sendOffsetsToTransaction(offsets, "test-group")
Review comment:
Using `Map(new TopicPartition(topic1, 0) -> new
OffsetAndMetadata(0)).asJava` is better. No need to import
scala.collection.mutable package.
----------------------------------------------------------------
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:
[email protected]