Skip to content

Commit 44d031f

Browse files
One more try at deleting the tmp check file correctly
1 parent 80f3ffb commit 44d031f

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/main/java/com/glencoesoftware/bioformats2raw/Converter.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,20 +1209,24 @@ public Integer call() throws Exception {
12091209
// a temp file is created and set as executable
12101210
// in the noexec case, setting as executable is expected to silently fail
12111211
File tmpdirCheck = File.createTempFile("noexec-test", ".txt");
1212-
// expect 'success' to be true in the noexec case, even though
1213-
// the file will not actually be executable
1214-
boolean success = tmpdirCheck.setExecutable(true);
1215-
if (!success || !tmpdirCheck.canExecute()) {
1216-
String msg = System.getProperty("java.io.tmpdir") +
1217-
" is noexec; fix it or specify a different java.io.tmpdir";
1218-
if (getWarnNoExec()) {
1219-
LOGGER.warn(msg);
1220-
}
1221-
else {
1222-
throw new RuntimeException(msg);
1212+
try {
1213+
// expect 'success' to be true in the noexec case, even though
1214+
// the file will not actually be executable
1215+
boolean success = tmpdirCheck.setExecutable(true);
1216+
if (!success || !tmpdirCheck.canExecute()) {
1217+
String msg = System.getProperty("java.io.tmpdir") +
1218+
" is noexec; fix it or specify a different java.io.tmpdir";
1219+
if (getWarnNoExec()) {
1220+
LOGGER.warn(msg);
1221+
}
1222+
else {
1223+
throw new RuntimeException(msg);
1224+
}
12231225
}
12241226
}
1225-
tmpdirCheck.delete();
1227+
finally {
1228+
tmpdirCheck.delete();
1229+
}
12261230

12271231
OpenCVTools.loadOpenCV();
12281232

0 commit comments

Comments
 (0)