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

OutputStream.write() contains some logic which is not reachable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P5 P5
    • 6
    • 5.0
    • core-libs
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      jdk 1.4.2_09, 1.5.0_04, 6.0_50

      ADDITIONAL OS VERSION INFORMATION :
      Windows

      A DESCRIPTION OF THE PROBLEM :
      I have copied part of write method from java.io.OutputStream class's source code -

      public void write(byte b[], int off, int len) throws IOException {
      if (b == null) {
      throw new NullPointerException();
      } else if ((off < 0) || (off > b.length) || (len < 0) ||
      ((off + len) > b.length) || ((off + len) < 0)) {
      throw new IndexOutOfBoundsException();
      }

      In this method the logic (off + len) < 0) is not rechable because if this condition has to satisfy then either off < 0 or len < 0 has to be satisfied.
      so this code will never be reached and it is not required.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------


      public void write(byte b[], int off, int len) throws IOException {
      if (b == null) {
      throw new NullPointerException();
      } else if ((off < 0) || (off > b.length) || (len < 0) ||
      ((off + len) > b.length) || ((off + len) < 0)) {
      throw new IndexOutOfBoundsException();
      }


      ---------- END SOURCE ----------

            iris Iris Clark
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: