Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

[NSE-1114] Remove tmp directory after application exits #1115

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import org.apache.commons.io.FileUtils;

/** Helper class for JNI related operations. */
public class JniUtils {
private static final String LIBRARY_NAME = "spark_columnar_jni";
Expand Down Expand Up @@ -80,6 +82,7 @@ private JniUtils(String _tmp_dir) throws IOException, IllegalAccessException, Il
} else {
Path folder = Paths.get(_tmp_dir);
Path path = Files.createTempDirectory(folder, "spark_columnar_plugin_");
FileUtils.forceDeleteOnExit(new File(path.toUri()));
tmp_dir = path.toAbsolutePath().toString();
}
}
Expand Down Expand Up @@ -146,6 +149,7 @@ private static void loadLibraryFromJar(String source_jar, String tmp_dir) throws
File tmp_dir_handler = new File(tmp_dir + "/tmp");
if (!tmp_dir_handler.exists()) {
tmp_dir_handler.mkdirs();
FileUtils.forceDeleteOnExit(tmp_dir_handler);
}

if (urlConnection instanceof JarURLConnection) {
Expand Down