Repository navigation
Conversation
Translate only numeric header parsing failures to IOException so the existing backup recovery path can run. Generated-by: OpenAI Codex
…covery Cover truncated/invalid count and CRC headers, bad backups, integrity mismatch controls, and valid-primary precedence. Generated-by: OpenAI Codex
RockteMQ-AI
left a comment
There was a problem hiding this comment.
LGTM. The fix improves error handling for corrupted checkpoint headers.
Summary
Wrapped Integer.parseInt() calls in CheckpointFile.read() to convert NumberFormatException to IOException with context.
Analysis
Checkpoint files have a two-line header (expected line count + CRC). If these lines are corrupted or truncated, the original code would throw a raw NumberFormatException without context. The fix converts this to an IOException with the file path included, which allows the checkpoint recovery mechanism to gracefully fall back to the backup file.
The test suite comprehensively covers malformed headers (truncated, non-numeric count, non-numeric CRC), fallback behavior, and valid primary precedence. All edge cases are well-covered.
Automated review by github-manager-bot
Which Issue(s) This PR Fixes
Fixes #11460
Brief Description
Convert NumberFormatException from the two numeric checkpoint header fields to IOException with the file path and original cause. This lets the existing .bak recovery work for empty, truncated or malformed headers. The catch is limited to header parsing; serializer exceptions, empty-state behavior and normal primary precedence are not changed.
This is distinct from #11032, which handles persisting/reading empty checkpoint state.
How Did You Test This Change?
mvn -B -pl remoting -am -Dtest=CheckpointFileHeaderTest,CheckpointFileTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false test.No live broker or HA failover test is claimed.
AI assistance: OpenAI Codex was used for investigation, implementation and tests; commits include tooling provenance.