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

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 6
    • Affects Version/s: 1.4.2, 5.0
    • Component/s: 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.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: