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

Regression: URL.openStream() does not throw exception with unknown host

    Details

    • Subcomponent:
    • Resolved In Build:
      beta2
    • CPU:
      x86, sparc
    • OS:
      linux, solaris_7, solaris_8, windows_98
    • Verification:
      Verified

      Description



      Name: dfR10049 Date: 07/24/2001



      Java(TM) Plug-in: Version 1.4.0
      Using JRE version 1.4.0-beta Java HotSpot(TM) Client VM

      does not throw exception when try to open stream with URL created
      with unknown host. (on Solaris 2.8 with Netscape 4.76)

      Plugin version of 1.3.1 throws java.io.FileNotFoundException in this case

      This is the test demonstrating the bug:
      ------------------------------------------------------------------
      import java.net.URL;
      import java.net.MalformedURLException;
      import java.io.InputStream;
      import java.applet.Applet;
      import java.awt.Graphics;


      public class IOE extends Applet {

          public static void main (String args[]){
              System.out.println(test());
          }

          public void paint(Graphics g) {
              String result = test();
              System.out.println(result);
              g.drawString(result, 50, 25);
          }

          static String test() {
              URL url = null;
              try {
                  url = new URL("http://unknownhost/files");
              } catch (MalformedURLException e) {
                  return "TEST FAILED: Unexpected exception:" + e;
              }

              try {
                  InputStream is = url.openStream();
                  return "TEST FAILED with " + url + "no exceptions, stream: " + is;

              } catch (Exception e) {
                  return "TEST PASSED. " + e + " thrown";
              }
          }
      }
      ---------------------- pluginIOE.html -------------------------------
      <html>
      <title> URL Test</title>
      <body>
      <center><h1> URL.openStream() with unknown hosts </h1></center>
      <hr>

      <EMBED type="application/x-java-applet;version=1.3"
             width="800"
             height="200"
             align="baseline"
             code="IOE.class">
         <NOEMBED>
            No Java 2 SDK, Standard Edition v 1.3 support for APPLET!!
         </NOEMBED>
      </EMBED>


      </body>
      </html>

      ---------------------------------------------------------------------
      output from the test:

      running from command line:
      #> java IOE
      TEST PASSED. java.net.UnknownHostException: unknownhost throw

      #---

      running with:
      Java(TM) Plug-in: Version 1.3.1
      Using JRE version 1.3.1 Java HotSpot(TM) Client VM(

      TEST PASSED. java.io.FileNotFoundException: http://unknownhost/files throwng

      #---

      running with:
      Java(TM) Plug-in: Version 1.4.0
      Using JRE version 1.4.0-beta_refresh Java HotSpot(TM) Client VM

      TEST FAILED with http://unknownhost/files no exceptions, stream: sun.plugin.usability.ProgressInputStream@3a4211


      It is incorrect behavior to return input stream on inexistent resource.
      It breaks compatibility. The correct way is throwing IOException.

      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              stanleyh Stanley Ho (Inactive)
              Reporter:
              fdasunw Fda Fda (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: