[ 
https://issues.apache.org/jira/browse/HADOOP-10440?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tsz Wo Nicholas Sze updated HADOOP-10440:
-----------------------------------------

    Description: 
In the HarFsInputStream of HarFileSystem, when reading data by interface "int 
read(byte[] b)", "int read(byte[] b, int offset, int len)" wille be called and 
position wille be update, so position  need not be update in interface "int 
read(byte[] b)"
{code}
//HarFileSystem.HarFsInputStream
      public synchronized int read(byte[] b) throws IOException {
        int ret = read(b, 0, b.length);
        if (ret != -1) {
          position += ret;
        }
        return ret;
      }

      /**
       *
       */
      public synchronized int read(byte[] b, int offset, int len)
        throws IOException {
        int newlen = len;
        int ret = -1;
        if (position + len > end) {
          newlen = (int) (end - position);
        }
        // end case
        if (newlen == 0)
          return ret;
        ret = underLyingStream.read(b, offset, newlen);
        position += ret;
        return ret;
      }
{code}

  was:
In the HarFsInputStream of HarFileSystem, when reading data by interface "int 
read(byte[] b)", "int read(byte[] b, int offset, int len)" wille be called and 
position wille be update, so position  need not be update in interface "int 
read(byte[] b)"

      public synchronized int read(byte[] b) throws IOException {
        int ret = read(b, 0, b.length);
        if (ret != -1) {
          position += ret;
        }
        return ret;
      }

      /**
       *
       */
      public synchronized int read(byte[] b, int offset, int len)
        throws IOException {
        int newlen = len;
        int ret = -1;
        if (position + len > end) {
          newlen = (int) (end - position);
        }
        // end case
        if (newlen == 0)
          return ret;
        ret = underLyingStream.read(b, offset, newlen);
        position += ret;
        return ret;
      }


> HarFsInputStream of HarFileSystem, when reading data, computing the position 
> has bug
> ------------------------------------------------------------------------------------
>
>                 Key: HADOOP-10440
>                 URL: https://issues.apache.org/jira/browse/HADOOP-10440
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: fs
>    Affects Versions: 2.3.0
>            Reporter: guodongdong
>            Assignee: guodongdong
>             Fix For: 2.4.0
>
>         Attachments: HADOOP-10440-patch
>
>
> In the HarFsInputStream of HarFileSystem, when reading data by interface "int 
> read(byte[] b)", "int read(byte[] b, int offset, int len)" wille be called 
> and position wille be update, so position  need not be update in interface 
> "int read(byte[] b)"
> {code}
> //HarFileSystem.HarFsInputStream
>       public synchronized int read(byte[] b) throws IOException {
>         int ret = read(b, 0, b.length);
>         if (ret != -1) {
>           position += ret;
>         }
>         return ret;
>       }
>       /**
>        *
>        */
>       public synchronized int read(byte[] b, int offset, int len)
>         throws IOException {
>         int newlen = len;
>         int ret = -1;
>         if (position + len > end) {
>           newlen = (int) (end - position);
>         }
>         // end case
>         if (newlen == 0)
>           return ret;
>         ret = underLyingStream.read(b, offset, newlen);
>         position += ret;
>         return ret;
>       }
> {code}



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

Reply via email to