Skip to content

Commit

Permalink
Merge pull request #332 from ascopes/task/GH-372-diagnostics
Browse files Browse the repository at this point in the history
GH-327: Report offending paths when failing to open ZIP archives
  • Loading branch information
ascopes authored Aug 19, 2024
2 parents 7b20f74 + 7f8b514 commit 9ab25d2
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,15 @@ private FileSystem openZip(Path path) throws IOException {
// Impl note: unlike other constructors, calling this multiple times on the same path
// will open multiple file system objects. Other constructors do not appear to do this,
// so would not be thread-safe for concurrent plugin executions.
return FileUtils.getFileSystemProvider("jar")
.newFileSystem(path, Map.of());
try {
return FileUtils.getFileSystemProvider("jar")
.newFileSystem(path, Map.of());

} catch (Exception ex) {
// The JDK will raise vague exceptions if we try to read something that is not a zip file.
// See ZipFileSystemProvider#getZipFileSystem for an example.
throw new IOException("Failed to open " + path + " as a valid ZIP/JAR archive", ex);
}
}

private Path getExtractionRoot() {
Expand Down

0 comments on commit 9ab25d2

Please sign in to comment.