From 3df35aa373dacf56d0049166c72a5ae8d9d50584 Mon Sep 17 00:00:00 2001 From: huangyuhui Date: Fri, 17 Aug 2018 21:53:29 +0800 Subject: [PATCH] Translate ZipError into ZipException since ZipError is not IOException --- .../java/org/jackhuang/hmcl/util/CompressingUtils.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/CompressingUtils.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/CompressingUtils.java index b19651da7..de4167590 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/CompressingUtils.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/CompressingUtils.java @@ -26,6 +26,8 @@ import java.nio.file.spi.FileSystemProvider; import java.util.HashMap; import java.util.Map; import java.util.Optional; +import java.util.zip.ZipError; +import java.util.zip.ZipException; /** * Utilities of compressing @@ -66,7 +68,12 @@ public final class CompressingUtils { env.put("encoding", encoding); if (useTempFile) env.put("useTempFile", true); - return ZIPFS_PROVIDER.newFileSystem(zipFile, env); + try { + return ZIPFS_PROVIDER.newFileSystem(zipFile, env); + } catch (ZipError error) { + // Since Java 8 throws ZipError stupidly + throw new ZipException(error.getMessage()); + } } /**