Skip to content

[java] Model ZipFile.getInputStream and JarFile.getManifest as throwing IOException - #2289

Merged
dulmarod merged 1 commit into
meta:mainfrom
tanvir-ux:fix/pulse-zipfile-getinputstream-throws
Oct 29, 2026
Merged

dulmarod merged 1 commit into
meta:mainfrom
tanvir-ux:fix/pulse-zipfile-getinputstream-throws

Conversation

@tanvir-ux

Copy link
Copy Markdown
Contributor

Summary

ZipFile.getInputStream and JarFile.getManifest read the archive and may throw IOException, 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 test FN_withZipFileBad in ResourceLeaks.java shows this.

  • Move getInputStream and getManifest out of the no-op ZipFile accessor list.
  • Model them with Resource.use ~exn_class_name:"java.io.IOException", the same way the RandomAccessFile and InputStream reads 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_withZipFileBad is renamed to withZipFileBad and is now reported.
  • jarFileNotClosedAfterGetManifestBad gets a second report, for the path where getManifest() throws.
  • zipFileReadEntryClosedOk and jarFileClosedAfterGetManifestOk (try-with-resources) stay clean.

Test plan

  • Before (main @ 1e90289): withZipFileBad is not reported
  • After: PULSE_RESOURCE_LEAK for withZipFileBad and for the getManifest exception path; the Ok cases stay clean
  • make direct_java_pulse_test: the only issues.exp changes 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.)
  • ocamlformat 0.29.0 reports no changes for PulseModelsJava.ml

…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.
@meta-cla meta-cla Bot added the CLA Signed label Oct 29, 2026
@dulmarod
dulmarod merged commit 333eda4 into meta:main Oct 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants