Browse Source

HADOOP-864. Fix 'bin/hadoop -jar' to operate correctly when hadoop.tmp.dir does not yet exist. Contributed by Owen.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@494249 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 years ago
parent
commit
197dd1ea8a
2 changed files with 14 additions and 7 deletions
  1. 3 0
      CHANGES.txt
  2. 11 7
      src/java/org/apache/hadoop/util/RunJar.java

+ 3 - 0
CHANGES.txt

@@ -14,6 +14,9 @@ Trunk (unreleased changes)
  4. HADOOP-600.  Fix a race condition in JobTracker.
     (Arun C Murthy via cutting)
 
+ 5. HADOOP-864.  Fix 'bin/hadoop -jar' to operate correctly when
+    hadoop.tmp.dir does not yet exist.  (omalley via cutting)
+
 
 Release 0.10.0 - 2007-01-05
 

+ 11 - 7
src/java/org/apache/hadoop/util/RunJar.java

@@ -106,14 +106,18 @@ public class RunJar {
     }
     mainClassName = mainClassName.replaceAll("/", ".");
 
-    final File workDir = File.createTempFile("hadoop-unjar","", 
-        new File( new Configuration().get("hadoop.tmp.dir")) );
+    File tmpDir = new File(new Configuration().get("hadoop.tmp.dir"));
+    tmpDir.mkdirs();
+    if (!tmpDir.isDirectory()) { 
+      System.err.println("Mkdirs failed to create " + tmpDir);
+      System.exit(-1);
+    }
+    final File workDir = File.createTempFile("hadoop-unjar", "", tmpDir );
     workDir.delete();
-    if (!workDir.mkdirs()) {
-      if (!workDir.isDirectory()) {
-        System.err.println("Mkdirs failed to create " + workDir.toString());
-        System.exit(-1);
-      }
+    workDir.mkdirs();
+    if (!workDir.isDirectory()) {
+      System.err.println("Mkdirs failed to create " + workDir);
+      System.exit(-1);
     }
 
     Runtime.getRuntime().addShutdownHook(new Thread() {