Browse Source

HADOOP-3183. Fix TestJobShell to use 'ls' instead of java.io.File::exists
since cygwin symlinks are unsupported. Contributed by Mahadev konar



git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.17@646158 13f79535-47bb-0310-9956-ffa450edef68

Christopher Douglas 17 năm trước cách đây
mục cha
commit
6dc24b1646
2 tập tin đã thay đổi với 21 bổ sung4 xóa
  1. 4 0
      CHANGES.txt
  2. 17 4
      src/test/testshell/ExternalMapReduce.java

+ 4 - 0
CHANGES.txt

@@ -526,6 +526,10 @@ Release 0.17.0 - Unreleased
     HADOOP-3018. Fix the eclipse plug-in contrib wrt removed deprecated
     methods (taton)
 
+    HADOOP-3183. Fix TestJobShell to use 'ls' instead of java.io.File::exists
+    since cygwin symlinks are unsupported.
+    (Mahadev konar via cdouglas)
+
 Release 0.16.3 - Unreleased
 
   BUG FIXES

+ 17 - 4
src/test/testshell/ExternalMapReduce.java

@@ -63,11 +63,24 @@ public class ExternalMapReduce
     if (classpath.indexOf("testjob.jar") == -1) {
       throw new IOException("failed to find in the library " + classpath);
     }
-    File f = new File("files_tmp");
-    //check for files 
-    if (!f.exists()) {
-      throw new IOException("file file_tmpfile not found");
+    //fork off ls to see if the file exists.
+    // java file.exists() will not work on 
+    // cygwin since it is a symlink
+    String[] argv = new String[2];
+    argv[0] = "ls";
+    argv[1] = "files_tmp";
+    Process p = Runtime.getRuntime().exec(argv);
+    int ret = -1;
+    try {
+      ret = p.waitFor();
+    } catch(InterruptedException ie) {
+      //do nothing here.
+    }
+    if (ret != 0) {
+      throw new IOException("files_tmp does not exist");
     }
+    
+    //check for files 
   }
 
   public void reduce(WritableComparable key, Iterator<Writable> values,