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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.18.0
    • 0.19.0
    • fs/s3
    • None
    • 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

        1. hadoop-3640.patch
          0.5 kB
          Thomas White

        Activity

          People

            tomwhite Thomas White
            tomwhite Thomas White
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: