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

URL.getContent() throws unexpected NPE under netscape plugin

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.0
    • deploy
    • sparc
    • solaris_2.6

      Name: acR10002 Date: 11/09/2001

      The spec for java.net.URL.getContent() reads:

      --------------- javadoc for URL.getContent() jdk1.4.0b84 ---
      public final Object getContent()
                              throws IOException
      Gets the contents of this URL. This method is a shorthand for:
                    openConnection().getContent()

           Returns:
               the contents of this URL.
           Throws:
               IOException - if an I/O exception occurs.
      ------------------------------------------------------------

      However, if an attempt is made to get the content of non-existing URL, the
      NPE is thrown instead of IOException. This bug appears if one loads the
      following sample applet under netscape plugin (Solaris 2.8):
      -------- test.html -----------
      <html>
      <EMBED type="application/x-java-applet;version=1.4"
              width="600"
              height="400"
              code="Test"
              codebase="file:."
       </EMBED>
      </html>
      -----------------------------

      ------------ Test.java --------
      import java.applet.Applet;
      import java.net.*;
      import java.io.*;

      public class Test extends Applet {
          public void start() {
              URL url = null;
              try {
                  url = new URL("http://swordfishtrambone/files/index.html");
              } catch (MalformedURLException e) {
                  System.err.println("Unexpected exception:" + e);
                  return;
              }
              try {
                  url.getContent();
                  System.err.println("No exception thrown");
              } catch (java.io.IOException e) {
                  System.err.println("IOException:" + e);
              }
          }
      }
      -------------------------------
      -> uname -a
      SunOS archer 5.8 Generic_108528-06 sun4u sparc SUNW,Ultra-4

      Plugin Java Console output:
      -------------------------------------
      Java(TM) Plug-in: Version 1.4.0
      Using JRE version 1.4.0-beta3 Java HotSpot(TM) Client VM
      ...
      java.lang.NullPointerException
      at sun.plugin.cache.Cache.getFileExtension(Cache.java:262)
      at sun.plugin.cache.FileCache.isSupported(FileCache.java:186)
      at sun.plugin.cache.FileCache.get(FileCache.java:126)
      at
      sun.plugin.net.protocol.http.HttpURLConnection.connectWithCache(HttpURLConnection.java:198)
      at
      sun.plugin.net.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:144)
      at
      sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:290)
      at java.net.URLConnection.getContent(URLConnection.java:585)
      at java.net.URL.getContent(URL.java:970)
      at Test.start(Test.java:18)
      at sun.applet.AppletPanel.run(AppletPanel.java:358)
      at java.lang.Thread.run(Thread.java:539)

      ------------------------------------


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

            mcolburnsunw Michael Colburn (Inactive)
            aycsunw Ayc Ayc (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: