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

Commit

Permalink
delete tmp dir when application exit (#1115)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackylee-ch authored Sep 21, 2022
1 parent 03610d3 commit 5f543d0
Showing 1 changed file with 4 additions and 0 deletions.
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

0 comments on commit 5f543d0

Please sign in to comment.