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

URL.openStream hangs on an empty page.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • core-libs
    • x86
    • windows_2000



      Name: nt126004 Date: 01/22/2002


      FULL PRODUCT VERSION :
      FOR JDK 1.4.0

      Java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)


      FULL OPERATING SYSTEM VERSION :
        Windows 2000 Professional



      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Apache webserver 1.3.22

      Apache Tomcat 4.0.1

      A DESCRIPTION OF THE PROBLEM :
      When I first call java.net.URL.openStream() method for the
      page containing no data, the method hangs for 15 seconds or
      longer before returning -1. I verified that the stream is
      closed prompty using telnet, but the call to the method
      just hung for 15 seconds. The problem does not exist if
      the page contains any charactor.

      Here's the code snipet:

      import java.net.*;
      import java.io.*;

      public class LongURL {
      public static void main(String[] args) {
       try {
        URL emptyPageURL
          = new URL("http://localhost/emptypage.html");
        InputStream is= emptyPageURL.openStream();
      System.out.println(System.currentTimeMillis());
        int c = is.read(); /* It takes 15 seconds to return -1 */
        System.out.println(System.currentTimeMillis());
        System.out.println("returned: "+c);
        } catch (Exception e) { e.printStackTrace(); }
      }
      }

      As the name suggests, the emptypage.html is empty,
      containing no charactor.


      I tested the same code with JDK 1.3.1, and the same problem
      exists. However when I tested with JDK 1.2.2, the call
      returned -1 promptly. So the problem didn't exist for JDK
      1.2.2.

      REGRESSION. Last worked in version 1.2.2

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      When new URL("http://localhost/emptypage.html").openStream
      ().read() is called, it should return -1 immediately.



      This bug can be reproduced always.
      (Review ID: 138071)
      ======================================================================

            alanb Alan Bateman
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: