瀏覽代碼

HADOOP-2422. dfs -cat multiple files fail with 'Unable to write to
output stream'. (Raghu Angadi via dhruba)
svn merge -c 605220 from trunk.



git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/branches/branch-0.15@605221 13f79535-47bb-0310-9956-ffa450edef68

Dhruba Borthakur 17 年之前
父節點
當前提交
4c98938258
共有 3 個文件被更改,包括 13 次插入2 次删除
  1. 2 0
      CHANGES.txt
  2. 5 1
      src/java/org/apache/hadoop/fs/FsShell.java
  3. 6 1
      src/test/org/apache/hadoop/dfs/TestDFSShell.java

+ 2 - 0
CHANGES.txt

@@ -69,6 +69,8 @@ Release 0.15.1 - 2007-11-27
     by HADOOP-1917 weren't correctly copied over to the trunk/docs directory. 
     Also fixed a couple of minor typos and broken links. (acmurthy)
 
+    HADOOP-2422.  dfs -cat multiple files fail with 'Unable to write to 
+    output stream'.  (Raghu Angadi via dhruba)
 
 Release 0.15.0 - 2007-11-2
 

+ 5 - 1
src/java/org/apache/hadoop/fs/FsShell.java

@@ -97,7 +97,11 @@ public class FsShell extends Configured implements Tool {
       throw new IOException("Source must be a file.");
     }
     FSDataInputStream in = fs.open(src);
-    IOUtils.copyBytes(in, System.out, getConf(), true);
+    try {
+      IOUtils.copyBytes(in, System.out, getConf(), false);
+    } finally {
+      in.close();
+    }
   }
 
   /**

+ 6 - 1
src/test/org/apache/hadoop/dfs/TestDFSShell.java

@@ -283,12 +283,16 @@ public class TestDFSShell extends TestCase {
       Path myFile = new Path("/test/mkdirs/myFile");
       writeFile(fileSys, myFile);
       assertTrue(fileSys.exists(myFile));
+      Path myFile2 = new Path("/test/mkdirs/myFile2");      
+      writeFile(fileSys, myFile2);
+      assertTrue(fileSys.exists(myFile2));
 
       // Verify that we can read the file
       {
-        String[] args = new String[2];
+        String[] args = new String[3];
         args[0] = "-cat";
         args[1] = "/test/mkdirs/myFile";
+        args[2] = "/test/mkdirs/myFile2";        
         int val = -1;
         try {
           val = shell.run(args);
@@ -298,6 +302,7 @@ public class TestDFSShell extends TestCase {
         }
         assertTrue(val == 0);
       }
+      fileSys.delete(myFile2);
 
       // Verify that we can get with and without crc
       {