chia7712 commented on code in PR #19054:
URL: https://github.com/apache/kafka/pull/19054#discussion_r1978709881
##########
core/src/test/scala/unit/kafka/coordinator/transaction/TransactionLogTest.scala:
##########
@@ -235,7 +237,9 @@ class TransactionLogTest {
def testReadTxnRecordKeyCanReadUnknownMessage(): Unit = {
val record = new TransactionLogKey()
val unknownRecord = MessageUtil.toVersionPrefixedBytes(Short.MaxValue,
record)
- val key = TransactionLog.readTxnRecordKey(ByteBuffer.wrap(unknownRecord))
- assertEquals(UnknownKey(Short.MaxValue), key)
+ TransactionLog.readTxnRecordKey(ByteBuffer.wrap(unknownRecord))match {
Review Comment:
`) match {`
##########
core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:
##########
@@ -465,25 +465,21 @@ class TransactionStateManager(brokerId: Int,
fileRecords.readInto(buffer, 0)
MemoryRecords.readableRecords(buffer)
}
-
memRecords.batches.forEach { batch =>
for (record <- batch.asScala) {
require(record.hasKey, "Transaction state log's key should not
be null")
TransactionLog.readTxnRecordKey(record.key) match {
- case txnKey: TxnKey =>
- // load transaction metadata along with transaction state
Review Comment:
please keep this comment
##########
core/src/main/scala/kafka/coordinator/transaction/TransactionLog.scala:
##########
@@ -90,19 +90,15 @@ object TransactionLog {
/**
* Decodes the transaction log messages' key
*
- * @return the key
+ * @return left with the version if the key is not a transaction log key,
right with the transactional id otherwise
*/
- def readTxnRecordKey(buffer: ByteBuffer): BaseKey = {
+ def readTxnRecordKey(buffer: ByteBuffer): Either[Short,String] = {
Review Comment:
`Either[Short, String]`
--
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]