From 44d031f6b7c265c334c3611596b46c5a72c8104b Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Thu, 18 Jul 2024 09:34:08 -0500 Subject: [PATCH] One more try at deleting the tmp check file correctly --- .../bioformats2raw/Converter.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/glencoesoftware/bioformats2raw/Converter.java b/src/main/java/com/glencoesoftware/bioformats2raw/Converter.java index 00f7ab9..c45e87f 100644 --- a/src/main/java/com/glencoesoftware/bioformats2raw/Converter.java +++ b/src/main/java/com/glencoesoftware/bioformats2raw/Converter.java @@ -1209,20 +1209,24 @@ public Integer call() throws Exception { // a temp file is created and set as executable // in the noexec case, setting as executable is expected to silently fail File tmpdirCheck = File.createTempFile("noexec-test", ".txt"); - // expect 'success' to be true in the noexec case, even though - // the file will not actually be executable - boolean success = tmpdirCheck.setExecutable(true); - if (!success || !tmpdirCheck.canExecute()) { - String msg = System.getProperty("java.io.tmpdir") + - " is noexec; fix it or specify a different java.io.tmpdir"; - if (getWarnNoExec()) { - LOGGER.warn(msg); - } - else { - throw new RuntimeException(msg); + try { + // expect 'success' to be true in the noexec case, even though + // the file will not actually be executable + boolean success = tmpdirCheck.setExecutable(true); + if (!success || !tmpdirCheck.canExecute()) { + String msg = System.getProperty("java.io.tmpdir") + + " is noexec; fix it or specify a different java.io.tmpdir"; + if (getWarnNoExec()) { + LOGGER.warn(msg); + } + else { + throw new RuntimeException(msg); + } } } - tmpdirCheck.delete(); + finally { + tmpdirCheck.delete(); + } OpenCVTools.loadOpenCV();