From fe1f93396da923226c1bd2f5ab6309113c345d92 Mon Sep 17 00:00:00 2001 From: lujie Date: Thu, 21 Oct 2021 23:15:53 +0800 Subject: [PATCH 1/2] PIG-5417:Replace guava's Files.createTempDir() --- src/org/apache/pig/data/SchemaTupleBackend.java | 6 ++++-- src/org/apache/pig/data/SchemaTupleFrontend.java | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/org/apache/pig/data/SchemaTupleBackend.java b/src/org/apache/pig/data/SchemaTupleBackend.java index 21583001c9..6db126bd3c 100644 --- a/src/org/apache/pig/data/SchemaTupleBackend.java +++ b/src/org/apache/pig/data/SchemaTupleBackend.java @@ -27,6 +27,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.nio.file.Files; import java.util.Map; import java.util.Set; @@ -43,7 +44,6 @@ import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import com.google.common.io.Files; public class SchemaTupleBackend { private static final Log LOG = LogFactory.getLog(SchemaTupleBackend.class); @@ -81,7 +81,9 @@ private SchemaTupleBackend(Configuration jConf, boolean isLocal) { } codeDir = new File(jConf.get(PigConstants.LOCAL_CODE_DIR)); } else { - codeDir = Files.createTempDir(); + File tempDirBase = new File(System.getProperty("java.io.tmpdir")); + codeDir = Files.createTempDirectory( + tempDirBase.toPath(), System.currentTimeMillis() + "-").toFile(); codeDir.deleteOnExit(); } diff --git a/src/org/apache/pig/data/SchemaTupleFrontend.java b/src/org/apache/pig/data/SchemaTupleFrontend.java index b38e40dce6..2abee445dd 100644 --- a/src/org/apache/pig/data/SchemaTupleFrontend.java +++ b/src/org/apache/pig/data/SchemaTupleFrontend.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.nio.file.Files; import java.util.Map; import java.util.Properties; import java.util.Set; @@ -94,7 +95,9 @@ private static class SchemaTupleFrontendGenHelper { private Configuration conf; public SchemaTupleFrontendGenHelper(PigContext pigContext, Configuration conf) { - codeDir = Files.createTempDir(); + File tempDirBase = new File(System.getProperty("java.io.tmpdir")); + codeDir = Files.createTempDirectory( + tempDirBase.toPath(), System.currentTimeMillis() + "-").toFile(); codeDir.deleteOnExit(); LOG.debug("Temporary directory for generated code created: " + codeDir.getAbsolutePath()); From 13054a04cb67411bf86b46e89f8722cfc0bf349d Mon Sep 17 00:00:00 2001 From: lujie Date: Thu, 21 Oct 2021 23:18:19 +0800 Subject: [PATCH 2/2] remove Files --- src/org/apache/pig/data/SchemaTupleFrontend.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/org/apache/pig/data/SchemaTupleFrontend.java b/src/org/apache/pig/data/SchemaTupleFrontend.java index 2abee445dd..927030b77d 100644 --- a/src/org/apache/pig/data/SchemaTupleFrontend.java +++ b/src/org/apache/pig/data/SchemaTupleFrontend.java @@ -47,7 +47,6 @@ import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import com.google.common.io.Files; /** * This class is to be used at job creation time. It provides the API that lets code