From d308c5772860118337042bab18533564ce607e8f Mon Sep 17 00:00:00 2001 From: Ryan Hill Date: Mon, 10 May 2021 00:18:28 -0700 Subject: [PATCH] Code review feedback --- .../main/java/ai/onnxruntime/OnnxRuntime.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/java/src/main/java/ai/onnxruntime/OnnxRuntime.java b/java/src/main/java/ai/onnxruntime/OnnxRuntime.java index ccdb11bfa3..4bf4bfc97a 100644 --- a/java/src/main/java/ai/onnxruntime/OnnxRuntime.java +++ b/java/src/main/java/ai/onnxruntime/OnnxRuntime.java @@ -121,12 +121,12 @@ final class OnnxRuntime { * * @param file The file to remove. */ - private static void cleanUp(File file, boolean on_exit_only) { + private static void cleanUp(File file, boolean onExitOnly) { if (!file.exists()) { return; } logger.log(Level.FINE, "Deleting " + file); - if (on_exit_only || !file.delete()) { + if (onExitOnly || !file.delete()) { logger.log(Level.FINE, "Deleting " + file + " on exit"); file.deleteOnExit(); } @@ -148,7 +148,7 @@ final class OnnxRuntime { * @param library The bare name of the library. * @throws IOException If the file failed to read or write. */ - private static void load(Path tempDirectory, String library, boolean system_load) + private static void load(Path tempDirectory, String library, boolean systemLoad) throws IOException { // On Android, we simply use System.loadLibrary if (isAndroid()) { @@ -212,11 +212,16 @@ final class OnnxRuntime { os.write(buffer, 0, readBytes); } } - if (system_load) System.load(tempFile.getAbsolutePath()); - logger.log(Level.FINE, "Loaded native library '" + library + "' from resource path"); + if (systemLoad) { + System.load(tempFile.getAbsolutePath()); + logger.log(Level.FINE, "Loaded native library '" + library + "' from resource path"); + } + else { + logger.log(Level.FINE, "Extracted native library '" + library + "' from resource path"); + } } } finally { - cleanUp(tempFile, !system_load); + cleanUp(tempFile, !systemLoad); } }