RkGrit commented on code in PR #1245:
URL: https://github.com/apache/ratis/pull/1245#discussion_r2028164269


##########
ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLogReader.java:
##########
@@ -169,23 +163,28 @@ public long skip(long amt) throws IOException {
    */
   boolean verifyHeader() throws IOException {
     final int headerLength = SegmentedRaftLogFormat.getHeaderLength();
-    final int readLength = in.read(temp, 0, headerLength);
-    Preconditions.assertTrue(readLength <= headerLength);
-    final int matchLength = SegmentedRaftLogFormat.matchHeader(temp, 0, 
readLength);
-    Preconditions.assertTrue(matchLength <= readLength);
-
-    if (readLength == headerLength && matchLength == readLength) {
-      // The header is matched successfully
-      return true;
-    } else if (SegmentedRaftLogFormat.isTerminator(temp, matchLength, 
readLength - matchLength)) {
-      // The header is partially written
-      return false;
+    try{

Review Comment:
   Thanks very much for the patch! You are correct that we should minimize the 
scope of try-catch.



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