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

InputStream.read() has redundant null check

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs
    • x86
    • windows_xp



      Name: jl125535 Date: 09/16/2003


      A DESCRIPTION OF THE REQUEST :
      The java.io.InputStream.read(byte b[], int off, int len) method contains the condition "if (b != null)" within the for loop, even though a null check on the byte array is done explicitly in the beginning of the method (and it is previously accessed without a null check anyway).


      JUSTIFICATION :
      Performance in the most basic Java IO method is quite important!

      Although the JavaDoc encourages subclasses to override this method, in most cases the default implementation is used. Since this is in the base class for all Java input access, and is probably the most used method within it, it should be as optimized as possible, especially if this is a meaningless check performed on every single byte read from the stream.

      (Incident Review ID: 185434)
      ======================================================================

            iris Iris Clark
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: