AndrewJSchofield commented on code in PR #18136:
URL: https://github.com/apache/kafka/pull/18136#discussion_r1890488384


##########
core/src/main/scala/kafka/coordinator/transaction/TransactionLog.scala:
##########
@@ -144,32 +144,6 @@ object TransactionLog {
     }
   }
 

Review Comment:
   nit: I'd remove this blank line too.



##########
core/src/test/scala/unit/kafka/tools/DumpLogSegmentsTest.scala:
##########
@@ -831,6 +832,86 @@ class DumpLogSegmentsTest {
     )
   }
 
+  @Test
+  def testTransactionLogMessageParser(): Unit = {
+    val serde = new TransactionCoordinatorRecordSerde()
+    val parser = new TransactionLogMessageParser()
+
+    def serializedRecord(key: ApiMessageAndVersion, value: 
ApiMessageAndVersion): Record = {
+      val record = new CoordinatorRecord(key, value)
+      TestUtils.singletonRecords(
+        key = serde.serializeKey(record),
+        value = serde.serializeValue(record)
+      ).records.iterator.next
+    }
+
+    // The key is mandatory.
+    assertEquals(
+      "Failed to decode message at offset 0 using offset transaction-log 
decoder (message had a missing key)",
+      assertThrows(
+        classOf[RuntimeException],
+        () => parser.parse(TestUtils.singletonRecords(key = null, value = 
null).records.iterator.next)
+      ).getMessage
+    )
+
+    // A valid key and value should work.

Review Comment:
   I wonder whether we ought to have some testing of a more complicated value 
too. There are tagged fields and so on to consider.



-- 
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]

Reply via email to