From 17e1d621fec969454da14791380602134c5eb4ac Mon Sep 17 00:00:00 2001 From: Konloch Date: Wed, 2 Oct 2024 12:12:43 -0600 Subject: [PATCH] Cleanup On Decompiler Failure --- .../decompilers/impl/ProcyonDecompiler.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/ProcyonDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/ProcyonDecompiler.java index 30c67921..a0bd5e64 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/ProcyonDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/ProcyonDecompiler.java @@ -82,12 +82,13 @@ public class ProcyonDecompiler extends AbstractDecompiler @Override public String decompileClassNode(ClassNode cn, byte[] bytes) { + TempFile tempFile = null; String exception; try { - final TempFile tempFile = TempFile.createTemporaryFile(false, ".class"); - final File tempClassFile = tempFile.getFile(); + tempFile = TempFile.createTemporaryFile(false, ".class"); + File tempClassFile = tempFile.getFile(); //write the ClassNode bytes to the temp file try (FileOutputStream fos = new FileOutputStream(tempClassFile)) @@ -128,6 +129,10 @@ public class ProcyonDecompiler extends AbstractDecompiler exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw; } + //delete all temporary files + if(tempFile != null) + tempFile.delete(); + return PROCYON + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + NL + NL + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + NL + NL + exception; }