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

1.2.2 BufferedInputStream causes delay when wrapping Socket's InputStream

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • None
    • 1.2.2
    • core-libs
    • x86
    • linux



      Name: krC82822 Date: 09/30/2000


      Classic VM (build 1.2.2_006, green threads, nojit)

      I'm wrapping a BufferedInputStream around a Socket's input stream like:

      InputStream in = new BufferedInputStream(socket.getInputStream());

      Now, I can retrieve socket data (in fact, I mark and reset the stream without a
      hitch. However, the LAST .read() will ALWAYS wait around 15 seconds before
      returning and saying that there's no data left in the stream.

      Not sure why the socket blocks like that, but setting timeouts and such does
      not fix the problem.. So, this may be a problem with Linux sockets. However,
      the problem can most easily be fixed in the BufferedInputStream's fill() method.

      In BufferedInputStream, if the following line could be changed from:

           int n = in.read(buf, pos, buf.length - pos);

      to:

           int n = (in.available()==0) ? 0 : in.read(buf, pos, buf.length - pos);

      Then the problem would go away.
      (Review ID: 110148)
      ======================================================================

            alanb Alan Bateman
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: