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

java.io.InputStream read(byte[]...) method throw error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.2.0
    • core-libs
    • generic
    • generic



      Name: gsC80088 Date: 11/24/98


      java.io.InputStream read(byte[]...)
      methods declare but do not throw
      java.io.IOException

      notice overloaded read(byte[]...) methods
      actual implementation:

          public int read(byte b[], int off, int len) throws IOException {
              if (len <= 0) {
                  return 0;
              }
       
              int c = read();
              if (c == -1) {
                  return -1;
              }
              b[off] = (byte)c;
       
              int i = 1;
              try {
                  for (; i < len ; i++) {
                      c = read();
                      if (c == -1) {
                          break;
                      }
                      if (b != null) {
                          b[off + i] = (byte)c;
                      }
                  }
              } catch (IOException ee) {
              }
              return i;
          }


      the try/catch blocks cause an intercept of the
      IOException without passing the exception up
      the stack. See:

      catch (IOException ee) { }

      This in effect eats the exception, taking no action
      and prevents notification beyond the scope of
      this method.
      (Review ID: 43377)
      ======================================================================

            mr Mark Reinhold
            gstone Greg Stone
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: