[ZEPPELIN-6463] Close the package.json reader in HeliumBundleFactory with try-with-resources - #5380
Open
big-cir wants to merge 1 commit into
Open
[ZEPPELIN-6463] Close the package.json reader in HeliumBundleFactory with try-with-resources#5380big-cir wants to merge 1 commit into
big-cir wants to merge 1 commit into
Conversation
…with try-with-resources
jongyoul
approved these changes
Aug 5, 2026
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.
What is this PR for?
HeliumBundleFactory.downloadPackage()stages a Helium package into its bundle directory, either by copying a local directory or by unpacking an npm tarball, and then reads thepackage.jsonit finds there to pull out thedependenciesandmainentries:The reader is never closed. There is no
close(), nofinallyand no try-with-resources, and Gson does not close a reader handed to it. Ownership stays with the caller.The descriptor is therefore released only once the garbage collector reclaims the
FileReader, becauseFileInputStreamregisters itself for cleanup. So this is not an unbounded leak, but the release is not deterministic: the descriptor stays open for as long as theFileReadergoes unreclaimed, which has nothing to do with the point where the parse finishes and the reader stops being useful. The same holds when parsing fails, since a malformedpackage.jsonmakes Gson raiseJsonSyntaxExceptionand the method exits without closing.This PR wraps the reader in a try-with-resources so the descriptor is released as soon as parsing finishes. Only
JsonReaderis declared as a resource, since closing it closes theFileReaderit wraps, which avoids a redundant second close.packageJsonis declared ahead of the block so the parsed result remains available to the rest of the method. Parsing behaviour and the resulting bundle setup are unchanged, and no signatures or access modifiers change.What type of PR is it?
Bug Fix
Todos
package.jsonreader opened indownloadPackageWhat is the Jira issue?
How should this be tested?
./mvnw package -pl zeppelin-server --am \ -Dtest='HeliumBundleFactoryTest,HeliumTest,HeliumLocalRegistryTest' \ -DfailIfNoTests=falseTests run: 9, Failures: 0, Errors: 0, Skipped: 0, andzeppelin-serverbuilds.Screenshots (if appropriate)
N/A
Questions: