Skip to content

Stop snapshot traversal after directory visit failures - #18379

Open
cragkhit wants to merge 1 commit into
apache:masterfrom
cragkhit:matcha-stop-after-directory-visit-failure
Open

Stop snapshot traversal after directory visit failures#18379
cragkhit wants to merge 1 commit into
apache:masterfrom
cragkhit:matcha-stop-after-directory-visit-failure

Conversation

@cragkhit

@cragkhit cragkhit commented Aug 1, 2026

Copy link
Copy Markdown

Hi. We are researchers from Mahidol University, Thailand, and the State University of Ceará, Brazil, working on a research project for improving open-source projects by using the latest accepted answer from Stack Overflow that matched your code snippet. We found this recommendation for improving your code from https://stackoverflow.com/a/18454342.

Note: Our study is approved by the Institutional Review Board of Mahidol University. You can find the participant information sheet explaining this study https://drive.google.com/file/d/1ml5AqrtWQ9pnifTQyTFTcWQmwp6RuPA7/view?usp=sharing.


Proposed change

Stopped recursive snapshot listing when postVisitDirectory reports a traversal failure.

Stopped recursive snapshot listing when postVisitDirectory reports a traversal failure.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the consensus module’s snapshot directory traversal helper to stop recursive listing when a directory visit finishes with an error (postVisitDirectory receives a non-null IOException), aligning traversal behavior with failure handling already present in visitFileFailed.

Changes:

  • Terminate Files.walkFileTree(...) traversal when postVisitDirectory reports an exception.
  • Add logging for directory post-visit failures before terminating traversal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 68 to +72
public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
if (exc != null) {
logger.info(ConsensusMessages.VISIT_FILE_FAILED, dir.toAbsolutePath(), exc);
return FileVisitResult.TERMINATE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants