Repository navigation
[java] Model ZipFile.getInputStream and JarFile.getManifest as throwing IOException - #2289
Merged
dulmarod merged 1 commit intoOct 29, 2026
Conversation
…ng IOException ZipFile.getInputStream and JarFile.getManifest read the archive and may throw IOException, but they were modeled as plain no-ops. An archive that is only closed on the normal path therefore was not reported when one of these calls throws (FN_withZipFileBad). Model both calls as uses of the archive that may throw IOException and do not close it.
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
ZipFile.getInputStreamandJarFile.getManifestread the archive and may throwIOException, but they were modeled as plain no-ops (Basic.skip). So when an archive is only closed on the normal path, the leak on the exception path was not reported. The existing testFN_withZipFileBadinResourceLeaks.javashows this.getInputStreamandgetManifestout of the no-op ZipFile accessor list.Resource.use ~exn_class_name:"java.io.IOException", the same way theRandomAccessFileandInputStreamreads are modeled. They do not close the archive.The other accessors (
entries,getEntry,getName,size, ...) do not throw checked exceptions and stay as no-ops.Tests
FN_withZipFileBadis renamed towithZipFileBadand is now reported.jarFileNotClosedAfterGetManifestBadgets a second report, for the path wheregetManifest()throws.zipFileReadEntryClosedOkandjarFileClosedAfterGetManifestOk(try-with-resources) stay clean.Test plan
withZipFileBadis not reportedPULSE_RESOURCE_LEAKforwithZipFileBadand for thegetManifestexception path; theOkcases stay cleanmake direct_java_pulse_test: the onlyissues.expchanges are those 2 lines. (Locally I also get the unrelated lambda-name differences in InvokeDynamic/TransitiveAccess that show up on main too with my javac; not committed.)ocamlformat0.29.0 reports no changes forPulseModelsJava.ml