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

Redundant comparison to null in java.io.InputStream.read(byte[],int,int)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 1.4.2, 5.0
    • core-libs
    • b25
    • generic, x86
    • generic, windows_xp

      This code improvement found by Bill Pugh and David Hovemeyer's findbugs program.
      David writes:




      M RCN: Redundant comparison to null in java.io.InputStream.read(byte[],int,int) At InputStream.java:[line 177]

              b[off] = (byte)c;

              int i = 1;
              try {
                  for (; i < len ; i++) {
                      c = read();
                      if (c == -1) {
                          break;
                      }
                      if (b != null) { // b can never be null here [line 177]
                          b[off + i] = (byte)c;
                      }
                  }
              } catch (IOException ee) {
              }
              return i;

      This would just slow things down a little. The check can be removed.

            martin Martin Buchholz
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: