Close the digest stream when shaDigestForFile can't read a file - #116
Merged
pjfanning merged 1 commit intoSep 7, 2026
Merged
Conversation
shaDigestForFile calls str.close() only after the read loop finishes, so an IOException part-way through leaks the stream. The caller, syncCacheWithLocalXsdFiles, swallows that exception - "unable to read digest... no problem, ignore then" - and carries straight on to the next file, so an sdownload -sync over a cache with unreadable .xsd files leaks one handle per file rather than failing. Wrap it in a try-with-resources. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BaseSchemaResourceManager.shaDigestForFilecloses the stream only after the read loop completes:An
IOExceptionpart-way through skips the close. The caller,syncCacheWithLocalXsdFiles, swallows it —— and carries on to the next file, so
sdownload -syncover a cache containing unreadable.xsdfiles leaks one handle per file instead of failing.Wrapped in a try-with-resources.
getMessageDigest().digest()moves inside the block; it reads the digest state and does not require the stream to be closed first.Added
SchemaResourceManagerStreamTest, which serves a stream that opens and then fails every read. It fails on trunk and passes with this change. Full suite: 3171 tests pass (170 skipped).🤖 Generated with Claude Code