Fix resource leaks in JunitReportReader and Bdd2Octane#51
Merged
Conversation
JunitReportReader now implements Closeable, closing both its XMLEventReader and the underlying InputStream. Bdd2Octane uses try-with-resources for the report reader and the output stream, ensuring resources are released even when processing fails. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
nissimshitrit
approved these changes
Apr 9, 2026
| try { | ||
| reader.close(); | ||
| } catch (XMLStreamException e) { | ||
| // best effort |
Collaborator
There was a problem hiding this comment.
I think it might be good to add log here so user will be aware what happen, I don't think it need to throw exception since closing file failure should not effect result
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.
Summary
JunitReportReadernow implementsCloseable, allowing callers to properly release its internalXMLEventReaderand the underlyingInputStreamBdd2Octane.run()uses try-with-resources for both theFileOutputStream(output) andJunitReportReader(per report file), ensuring streams are closed even on exceptionsContext
This is the same class of bug that caused a "Too many open files" error previously fixed in
FeatureFileLocator(commit 2d31c79, PR #18). TheBdd2Octane/JunitReportReadercode paths were not addressed at that time.Previously, if processing was interrupted by an exception mid-iteration, neither the report file input streams nor the output stream were closed. With many report files, this would exhaust file descriptors.
Verification