Author: rohini
Date: Tue Jan 17 00:49:47 2023
New Revision: 1906717

URL: http://svn.apache.org/viewvc?rev=1906717&view=rev
Log:
PIG-5417: Replace guava's Files.createTempDir() (xiaoheipangzi via rohini)

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/data/SchemaTupleBackend.java
    pig/trunk/src/org/apache/pig/data/SchemaTupleFrontend.java

Modified: pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1906717&r1=1906716&r2=1906717&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Tue Jan 17 00:49:47 2023
@@ -26,6 +26,8 @@ PIG-5282: Upgade to Java 8 (satishsaley
  
 IMPROVEMENTS
 
+PIG-5417: Replace guava's Files.createTempDir() (xiaoheipangzi via rohini)
+
 PIG-5429: Update hbase version from 2.0.0 to 2.4.14 (knoguchi)
 
 PIG-5428: Update hadoop2,3 and tez to recent versions (knoguchi)

Modified: pig/trunk/src/org/apache/pig/data/SchemaTupleBackend.java
URL: 
http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/data/SchemaTupleBackend.java?rev=1906717&r1=1906716&r2=1906717&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/data/SchemaTupleBackend.java (original)
+++ pig/trunk/src/org/apache/pig/data/SchemaTupleBackend.java Tue Jan 17 
00:49:47 2023
@@ -27,6 +27,7 @@ import java.io.IOException;
 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 org.apache.pig.impl.util.Utils;
 
 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,8 +81,14 @@ public class SchemaTupleBackend {
             }
             codeDir = new File(jConf.get(PigConstants.LOCAL_CODE_DIR));
         } else {
-            codeDir = Files.createTempDir();
-            codeDir.deleteOnExit();
+            try {
+                File tempDirBase = new 
File(System.getProperty("java.io.tmpdir"));
+                codeDir = Files.createTempDirectory(
+                              tempDirBase.toPath(), System.currentTimeMillis() 
+ "-").toFile();
+                codeDir.deleteOnExit();
+            } catch (IOException e) {
+                throw new RuntimeException("Unable to create temporary 
directory", e);
+            }
         }
 
         try {

Modified: pig/trunk/src/org/apache/pig/data/SchemaTupleFrontend.java
URL: 
http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/data/SchemaTupleFrontend.java?rev=1906717&r1=1906716&r2=1906717&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/data/SchemaTupleFrontend.java (original)
+++ pig/trunk/src/org/apache/pig/data/SchemaTupleFrontend.java Tue Jan 17 
00:49:47 2023
@@ -26,6 +26,7 @@ import java.io.File;
 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;
@@ -46,7 +47,6 @@ import org.apache.pig.impl.logicalLayer.
 
 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
@@ -94,8 +94,14 @@ public class SchemaTupleFrontend {
         private Configuration conf;
 
         public SchemaTupleFrontendGenHelper(PigContext pigContext, 
Configuration conf) {
-            codeDir = Files.createTempDir();
-            codeDir.deleteOnExit();
+            try {
+                File tempDirBase = new 
File(System.getProperty("java.io.tmpdir"));
+                codeDir = Files.createTempDirectory(
+                              tempDirBase.toPath(), System.currentTimeMillis() 
+ "-").toFile();
+                codeDir.deleteOnExit();
+            } catch (IOException e) {
+                throw new RuntimeException("Unable to create temporary 
directory", e);
+            }
             LOG.debug("Temporary directory for generated code created: "
                     + codeDir.getAbsolutePath());
             this.pigContext = pigContext;


Reply via email to