hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gera Shegalov (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-11012) hadoop fs -text of zero-length file causes EOFException
Date Wed, 27 Aug 2014 20:01:59 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-11012?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14112747#comment-14112747
] 

Gera Shegalov commented on HADOOP-11012:
----------------------------------------

Thanks for fixing this, [~eepayne]. LGTM overall. 

Now you read the "magic" twice however.  I woud change the original code just by enclosing
the switch statement into try-catch-EOF.

{code}
[tw-mbp-gshegalov hadoop-common (trunk)]$ git diff -b 
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java
index a72af7a..1f76177 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.fs.shell;
 
 import java.io.ByteArrayOutputStream;
+import java.io.EOFException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.LinkedList;
@@ -126,8 +127,9 @@ protected InputStream getInputStream(PathData item) throws IOException
{
     protected InputStream getInputStream(PathData item) throws IOException {
       FSDataInputStream i = (FSDataInputStream)super.getInputStream(item);
 
+      try {
         // Check type of stream first
-      switch(i.readShort()) {
+        switch (i.readShort()) {
           case 0x1f8b: { // RFC 1952
             // Must be gzip
             i.seek(0);
@@ -159,6 +161,8 @@ protected InputStream getInputStream(PathData item) throws IOException
{
             break;
           }
         }
+      } catch (EOFException ignored) {
+      }
 
       // File is non-compressed, or not a file container we know.
       i.seek(0);
{code}

> hadoop fs -text of zero-length file causes EOFException
> -------------------------------------------------------
>
>                 Key: HADOOP-11012
>                 URL: https://issues.apache.org/jira/browse/HADOOP-11012
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: fs
>    Affects Versions: 2.5.0
>            Reporter: Eric Payne
>            Assignee: Eric Payne
>         Attachments: HDFS-6915.201408271824.txt
>
>
> List:
> $ $HADOOP_PREFIX/bin/hadoop fs -ls /user/ericp/foo
> -rw-------   3 ericp hdfs          0 2014-08-22 16:37 /user/ericp/foo
> Cat:
> $ $HADOOP_PREFIX/bin/hadoop fs -cat /user/ericp/foo
> Text:
> $ $HADOOP_PREFIX/bin/hadoop fs -text /user/ericp/foo
> text: java.io.EOFException
> 	at java.io.DataInputStream.readShort(DataInputStream.java:315)
> 	at org.apache.hadoop.fs.shell.Display$Text.getInputStream(Display.java:130)
> 	at org.apache.hadoop.fs.shell.Display$Cat.processPath(Display.java:98)
> 	at org.apache.hadoop.fs.shell.Command.processPaths(Command.java:306)
> 	at org.apache.hadoop.fs.shell.Command.processPathArgument(Command.java:278)
> 	at org.apache.hadoop.fs.shell.Command.processArgument(Command.java:260)
> 	at org.apache.hadoop.fs.shell.Command.processArguments(Command.java:244)
> 	at org.apache.hadoop.fs.shell.Command.processRawArguments(Command.java:190)
> 	at org.apache.hadoop.fs.shell.Command.run(Command.java:154)
> 	at org.apache.hadoop.fs.FsShell.run(FsShell.java:287)
> 	at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
> 	at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84)
> 	at org.apache.hadoop.fs.FsShell.main(FsShell.java:340)



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message