Browse Source

commit e31e94e94fa8b162d4081477101539681a40f599
Author: Devaraj Das <ddas@yahoo-inc.com>
Date: Wed Oct 13 19:34:34 2010 -0700

Fixes an issue to do with TaskLog's static initializer causing NPEs when called from Streaming tasks.

+++ b/YAHOO-CHANGES.txt
+ Fixes an issue to do with TaskLog's static initializer
+ causing NPEs when called from Streaming tasks. (ddas)
+


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077737 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 years ago
parent
commit
6f26068a1d
1 changed files with 6 additions and 5 deletions
  1. 6 5
      src/mapred/org/apache/hadoop/mapred/TaskLog.java

+ 6 - 5
src/mapred/org/apache/hadoop/mapred/TaskLog.java

@@ -74,11 +74,6 @@ public class TaskLog {
     if (!LOG_DIR.exists()) {
       LOG_DIR.mkdirs();
     }
-    try {
-      localFS = FileSystem.getLocal(new Configuration());
-    } catch (IOException ie) {
-      throw new RuntimeException(ie);
-    }
   }
 
   public static File getTaskLogFile(TaskAttemptID taskid, boolean isCleanup,
@@ -167,6 +162,9 @@ public class TaskLog {
    * determined by checking the job's log directory.
    */
   static String obtainLogDirOwner(TaskAttemptID taskid) throws IOException {
+    if (localFS == null) {
+      localFS = FileSystem.getLocal(new Configuration());
+    }
     FileSystem raw = localFS.getRaw();
     Path jobLogDir = new Path(getJobDir(taskid.getJobID()).getAbsolutePath());
     FileStatus jobStat = raw.getFileStatus(jobLogDir);
@@ -237,6 +235,9 @@ public class TaskLog {
     Path indexFilePath = new Path(indexFile.getAbsolutePath());
     Path tmpIndexFilePath = new Path(tmpIndexFile.getAbsolutePath());
 
+    if (localFS == null) {// set localFS once
+      localFS = FileSystem.getLocal(new Configuration());
+    }
     localFS.rename (tmpIndexFilePath, indexFilePath);
   }