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


##########
transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionCoordinatorRecordSerde.java:
##########
@@ -16,32 +16,29 @@
  */
 package org.apache.kafka.coordinator.transaction;
 
+import org.apache.kafka.common.errors.UnsupportedVersionException;
 import org.apache.kafka.common.protocol.ApiMessage;
 import org.apache.kafka.coordinator.common.runtime.CoordinatorLoader;
 import org.apache.kafka.coordinator.common.runtime.CoordinatorRecordSerde;
-import org.apache.kafka.coordinator.transaction.generated.TransactionLogKey;
-import org.apache.kafka.coordinator.transaction.generated.TransactionLogValue;
+import 
org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordType;
 
 public class TransactionCoordinatorRecordSerde extends CoordinatorRecordSerde {
 
     @Override
     protected ApiMessage apiMessageKeyFor(short recordType) {
-        switch (recordType) {
-            case 0:
-                return new TransactionLogKey();
-            default:
-                throw new 
CoordinatorLoader.UnknownRecordTypeException(recordType);
+        try {
+            return CoordinatorRecordType.fromId(recordType).newRecordKey();
+        } catch (UnsupportedVersionException ex) {
+            throw new CoordinatorLoader.UnknownRecordTypeException(recordType);
         }
     }
 
     @Override
     protected ApiMessage apiMessageValueFor(short recordVersion) {

Review Comment:
   This really is the `recordType` again I think here. The version of the 
`TransactionLogValue` will have no bearing on the object which is created. It 
needs to be 0 here whether it's a v0 or v1 value.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to