Skip to content

Commit 29bf91e

Browse files
committed
Fix #157
1 parent 14e95e2 commit 29bf91e

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

tdlight-java/src/main/java/it/tdlight/util/NativeLibraryLoader.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.lang.reflect.Method;
2929
import java.net.URL;
3030
import java.nio.charset.StandardCharsets;
31+
import java.nio.file.FileSystemException;
3132
import java.nio.file.Files;
3233
import java.nio.file.Path;
3334
import java.nio.file.Paths;
@@ -263,20 +264,16 @@ public static void load(String originalName, ClassLoader loader) {
263264
// After we load the library it is safe to delete the file.
264265
// We delete the file immediately to free up resources as soon as possible,
265266
// and if this fails fallback to deleting on JVM exit.
266-
try {
267-
if (tmpFile != null && (!DELETE_NATIVE_LIB_AFTER_LOADING || !deleteIfExists(tmpFile))) {
268-
tmpFile.toFile().deleteOnExit();
269-
}
270-
} catch (IOException e) {
271-
throw new RuntimeException(e);
267+
if (tmpFile != null && (!DELETE_NATIVE_LIB_AFTER_LOADING || !deleteIfExists(tmpFile))) {
268+
tmpFile.toFile().deleteOnExit();
272269
}
273270
}
274271
}
275272

276-
private static boolean deleteIfExists(Path tmpFile) throws IOException {
273+
private static boolean deleteIfExists(Path tmpFile) {
277274
try {
278275
return Files.deleteIfExists(tmpFile);
279-
} catch (AccessDeniedException ex) {
276+
} catch (IOException ex) {
280277
return false;
281278
}
282279
}

0 commit comments

Comments
 (0)