Browse Source

Merge -r 593747:593748 from trunk to branch-0.15 to fix HADOOP-2174

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/branches/branch-0.15@593750 13f79535-47bb-0310-9956-ffa450edef68
Arun Murthy 18 năm trước cách đây
mục cha
commit
4e07ebd218
2 tập tin đã thay đổi với 12 bổ sung12 xóa
  1. 4 0
      CHANGES.txt
  2. 8 12
      src/java/org/apache/hadoop/util/CopyFiles.java

+ 4 - 0
CHANGES.txt

@@ -12,6 +12,10 @@ Release 0.15.1 -
     correct value of 'libhdfs.so', currently it is set to the absolute path of
     libhdfs.so. (acmurthy) 
 
+    HADOOP-2174.  Removed the unnecessary Reporter.setStatus call from
+    FSCopyFilesMapper.close which led to a NPE since the reporter isn't valid
+    in the close method. (Chris Douglas via acmurthy) 
+
 Release 0.15.0 - 2007-11-2
 
   INCOMPATIBLE CHANGES

+ 8 - 12
src/java/org/apache/hadoop/util/CopyFiles.java

@@ -235,11 +235,8 @@ public class CopyFiles implements Tool {
     private int skipcount = 0;
     private int copycount = 0;
 
-    // hack
-    private Reporter rep;
-
-    private void updateStatus() {
-      rep.setStatus("Copied: " + copycount + " Skipped: " + skipcount +
+    private void updateStatus(Reporter reporter) {
+      reporter.setStatus("Copied: " + copycount + " Skipped: " + skipcount +
                     " Failed: " + failcount);
     }
 
@@ -290,7 +287,7 @@ public class CopyFiles implements Tool {
           outc.collect(null, new Text("SKIP: " + srcstat.getPath()));
           ++skipcount;
           reporter.incrCounter(Counter.SKIP, 1);
-          updateStatus();
+          updateStatus(reporter);
           return;
         }
         // open src file
@@ -330,7 +327,7 @@ public class CopyFiles implements Tool {
       ++copycount;
       reporter.incrCounter(Counter.BYTESCOPIED, cbcopied);
       reporter.incrCounter(Counter.COPY, 1);
-      updateStatus();
+      updateStatus(reporter);
     }
 
     /** Mapper configuration.
@@ -368,12 +365,11 @@ public class CopyFiles implements Tool {
       FileStatus srcstat = value.input;
       Path dstpath = value.output;
       try {
-        rep = reporter;
         copy(srcstat, dstpath, out, reporter);
       } catch (IOException e) {
         ++failcount;
         reporter.incrCounter(Counter.FAIL, 1);
-        updateStatus();
+        updateStatus(reporter);
         final String sfailure = "FAIL " + dstpath + " : " +
                           StringUtils.stringifyException(e);
         out.collect(null, new Text(sfailure));
@@ -388,18 +384,18 @@ public class CopyFiles implements Tool {
               LOG.debug("Ignoring cleanup exception", ex);
             }
             // update status, so we don't get timed out
-            updateStatus();
+            updateStatus(reporter);
             Thread.sleep(3 * 1000);
           }
         } catch (InterruptedException inte) {
           throw (IOException)new IOException().initCause(inte);
         }
-        updateStatus();
+      } finally {
+        updateStatus(reporter);
       }
     }
 
     public void close() throws IOException {
-      updateStatus();
       if (0 == failcount || ignoreReadFailures) {
         return;
       }