https://bz.apache.org/bugzilla/show_bug.cgi?id=66584

            Bug ID: 66584
           Summary: ZipPackage can fail to handle excepions.
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: POI Overall
          Assignee: dev@poi.apache.org
          Reporter: zhong...@pku.org.cn
  Target Milestone: ---

ZipPackage has a constructor:

ZipPackage(InputStream in, PackageAccess access) throws IOException {
        super(access);
        ZipArchiveThresholdInputStream zis = ZipHelper.openZipStream(in); //
NOSONAR
        try {
            this.zipArchive = new ZipInputStreamZipEntrySource(zis);
        } catch (final IOException | RuntimeException e) {
            IOUtils.closeQuietly(zis);
            throw e;
        }
    }

Here, ZipHelper.openZipStream(in) can throw IOException, but it is not inside
the try statement. It can be put inside the try statement to avoid exceptions.
BTW, I notice that in the same class, IOException is caught and
InvalidOperationException is rethrown:

 private static ZipEntrySource openZipEntrySourceStream(FileInputStream fis)
throws InvalidOperationException {
 try {
            // open the zip input stream
            zis = ZipHelper.openZipStream(fis); // NOSONAR
        } catch (final IOException e) {
            // If the source cannot be acquired, abort (no resources to free at
this level)
            throw new InvalidOperationException("Could not open the file input
stream", e);
        }
        ...
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to