Skip to content

Report an unlistable directory as IOException instead of NullPointerException - #349

Merged
slachiewicz merged 1 commit into
masterfrom
agent/listfiles-null
Nov 8, 2026
Merged

slachiewicz merged 1 commit into
masterfrom
agent/listfiles-null

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

File.listFiles() returns null for a directory that exists but cannot be read. copyDirectoryStructure and cleanDirectoryOnExit dereferenced it and failed with a NullPointerException that named nothing; they now throw an IOException with the directory path, as cleanDirectory already did by returning. Found while replacing another copy of this utility, which skipped such a directory silently, with this one.

Verified: mvn verify → all tests pass; the new test skips where the directory stays readable (root, Windows).

…re and cleanDirectoryOnExit

File.listFiles() returns null when a directory cannot be read; both
methods dereferenced it and failed with a NullPointerException that
named nothing. cleanDirectory already checks for null.
@slachiewicz slachiewicz added the bug Something isn't working label Nov 8, 2026
@slachiewicz
slachiewicz marked this pull request as ready for review November 8, 2026 11:42
@slachiewicz
slachiewicz merged commit 30d3090 into master Nov 8, 2026
13 checks passed
@slachiewicz
slachiewicz deleted the agent/listfiles-null branch November 8, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant