From bd3bde76232f580477fb457b40258b3bae33788d Mon Sep 17 00:00:00 2001 From: Jason Gustafson Date: Mon, 6 Jan 2020 09:06:11 -0800 Subject: [PATCH] MINOR: Fix failing test case in TransactionLogTest (#7895) This patch fixes a brittle expectation on the `toString` implementation coming from `Set`. This was failing on jenkins with the following error: ``` java.lang.AssertionError: expected: but was: ``` Instead we convert the collection to a string directly. Reviewers: Boyang Chen , Rajini Sivaram --- .../scala/kafka/coordinator/transaction/TransactionLog.scala | 2 +- .../unit/kafka/coordinator/transaction/TransactionLogTest.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/kafka/coordinator/transaction/TransactionLog.scala b/core/src/main/scala/kafka/coordinator/transaction/TransactionLog.scala index 17e640ebb33..829e9e6bf65 100644 --- a/core/src/main/scala/kafka/coordinator/transaction/TransactionLog.scala +++ b/core/src/main/scala/kafka/coordinator/transaction/TransactionLog.scala @@ -281,7 +281,7 @@ object TransactionLog { case Some(txnMetadata) => s"producerId:${txnMetadata.producerId}," + s"producerEpoch:${txnMetadata.producerEpoch}," + s"state=${txnMetadata.state}," + - s"partitions=${txnMetadata.topicPartitions}," + + s"partitions=${txnMetadata.topicPartitions.mkString("[", ",", "]")}," + s"txnLastUpdateTimestamp=${txnMetadata.txnLastUpdateTimestamp}," + s"txnTimeoutMs=${txnMetadata.txnTimeoutMs}" } diff --git a/core/src/test/scala/unit/kafka/coordinator/transaction/TransactionLogTest.scala b/core/src/test/scala/unit/kafka/coordinator/transaction/TransactionLogTest.scala index e9bf6d51454..e9bdf3110a8 100644 --- a/core/src/test/scala/unit/kafka/coordinator/transaction/TransactionLogTest.scala +++ b/core/src/test/scala/unit/kafka/coordinator/transaction/TransactionLogTest.scala @@ -123,7 +123,7 @@ class TransactionLogTest { val (keyStringOpt, valueStringOpt) = TransactionLog.formatRecordKeyAndValue(transactionMetadataRecord) assertEquals(Some(s"transaction_metadata::transactionalId=$transactionalId"), keyStringOpt) assertEquals(Some(s"producerId:$producerId,producerEpoch:$producerEpoch,state=Ongoing," + - s"partitions=Set($topicPartition),txnLastUpdateTimestamp=0,txnTimeoutMs=$transactionTimeoutMs"), valueStringOpt) + s"partitions=[$topicPartition],txnLastUpdateTimestamp=0,txnTimeoutMs=$transactionTimeoutMs"), valueStringOpt) } @Test