Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-3640

NativeS3FsInputStream read() method for reading a single byte is incorrect

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.18.0
    • Fix Version/s: 0.19.0
    • Component/s: fs/s3
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      From Albert Chern:

      I think there may be a bug in the read() method of NativeS3InputStream, which looks like this:

      public synchronized int read() throws IOException {
          int result = in.read();
          if (result > 0) {
              pos += result;
          }
          return result;
      }
      

      The return value of InputStream.read() should be the next byte in the range 0 to 255, or -1 if there are no more bytes. So shouldn't this method look something like this?

      public synchronized int read() throws IOException {
          int result = in.read();
          if (result > -1) {
              pos ++;
          }
          return result;
      }
      

        Attachments

          Activity

            People

            • Assignee:
              tomwhite Tom White
              Reporter:
              tomwhite Tom White
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: