niket-goel commented on a change in pull request #10899:
URL: https://github.com/apache/kafka/pull/10899#discussion_r655696253



##########
File path: 
clients/src/main/java/org/apache/kafka/common/record/MemoryRecords.java
##########
@@ -664,4 +666,55 @@ private static void writeLeaderChangeMessage(ByteBuffer 
buffer,
         builder.close();
     }
 
+    public static MemoryRecords withSnapshotHeaderRecord(
+            long initialOffset,
+            long timestamp,
+            int leaderEpoch,
+            ByteBuffer buffer,
+            MetadataSnapshotHeaderRecord snapshotHeaderRecord) {
+        writeSnapshotHeaderRecord(buffer, initialOffset, timestamp, 
leaderEpoch, snapshotHeaderRecord);
+        buffer.flip();
+        return MemoryRecords.readableRecords(buffer);
+            }
+
+    private static void writeSnapshotHeaderRecord(ByteBuffer buffer,
+            long initialOffset,
+            long timestamp,
+            int leaderEpoch,
+            MetadataSnapshotHeaderRecord snapshotHeaderRecord) {
+        MemoryRecordsBuilder builder = new MemoryRecordsBuilder(

Review comment:
       You are right in that one of the underlying calls throws a few 
exceptions, but again looking at a similar implementation for the leader change 
message. Given that implementation (being canonical) does not implement a 
try/catch, I assumed that the API structure handles exceptions somewhere higher 
up in the stack. I guess that understanding is not correct. I will make similar 
changes for the leader change call stack as well then. Will ping offline about 
what the general exception handling mechanism here. 




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


Reply via email to