yx9o commented on code in PR #11463:
URL: https://github.com/apache/rocketmq/pull/11463#discussion_r4630122974


##########
common/src/main/java/org/apache/rocketmq/common/utils/CheckpointFile.java:
##########
@@ -103,11 +103,14 @@ private List<T> read(String filePath) throws IOException {
                 return result;
             }
             try (BufferedReader reader = 
Files.newBufferedReader(file.toPath())) {
-                // Read size
-                int expectedLines = Integer.parseInt(reader.readLine());
-
-                // Read block crc
-                int expectedCrc32 = Integer.parseInt(reader.readLine());
+                int expectedLines;
+                int expectedCrc32;
+                try {
+                    expectedLines = Integer.parseInt(reader.readLine());
+                    expectedCrc32 = Integer.parseInt(reader.readLine());
+                } catch (NumberFormatException e) {
+                    throw new IOException("Invalid checkpoint header, file=" + 
filePath, e);

Review Comment:
   If the primary header is corrupt and no `.bak` exists, `read()` now returns 
an empty list and `EpochFileCache` treats initialization as successful. Could 
we propagate the original error when there’s no backup to recover from?



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