From b507667c7525c149b377ed1308e12452ca59a3e0 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Thu, 5 Aug 2021 20:28:32 +0200 Subject: [PATCH] Retry zip files more aggressively This doesn't fix any issue, but may be useful in some cases, I guess? --- .../resources/ResourceContainerImporter.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceContainerImporter.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceContainerImporter.java index 62062823..ae14a3dc 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceContainerImporter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceContainerImporter.java @@ -73,16 +73,18 @@ public class ResourceContainerImporter try { //attempt to import using Java ZipInputStream - importZipInputStream(false); + return importZipInputStream(false); } - catch (IOException e) + catch (Throwable t) { - e.printStackTrace(); - - //fallback to apache commons ZipFile - importApacheZipFile(false); + try { + //fallback to apache commons ZipFile + return importApacheZipFile(false); + } catch (Throwable t1) { + t1.addSuppressed(t); + throw t1; + } } - return this; } /** @@ -93,10 +95,10 @@ public class ResourceContainerImporter { //TODO remove this .class check and just look for cafebabe if (name.endsWith(".class")) - addClassResource(name, stream); - else if(!classesOnly) - addResource(name, stream); - + return addClassResource(name, stream); + else if (!classesOnly) + return addResource(name, stream); + return this; }