Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6282204

(spec) DataInputStream.readLong() is not thread safe

XMLWordPrintable

    • b63
    • x86
    • windows_xp

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      in java.io.DataInputStream there is

      private byte readBuffer[] = new byte[8];

      ...

          public final long readLong() throws IOException {
              readFully(readBuffer, 0, 8);
              return (((long)readBuffer[0] << 56) +
                      ((long)(readBuffer[1] & 255) << 48) +
                      ((long)(readBuffer[2] & 255) << 40) +
                      ((long)(readBuffer[3] & 255) << 32) +
                      ((long)(readBuffer[4] & 255) << 24) +
                      ((readBuffer[5] & 255) << 16) +
                      ((readBuffer[6] & 255) << 8) +
                      ((readBuffer[7] & 255) << 0));
          }

      This is not Thread safe since there is only one byte[] array (readBuffer) for the one method and it is not synchronized...



      REPRODUCIBILITY :
      This bug can be reproduced always.
      ###@###.### 2005-06-08 06:54:52 GMT

            jhangalsunw Jayalaxmi Hangal (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: