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

jeditorpane.setPane(URL) throws RuntimeException if target has bad redirect

    Details

    • Subcomponent:
    • Introduced In Version:
      6
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_16"
      Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
      Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]


      A DESCRIPTION OF THE PROBLEM :
      Due to the problem shown in bug 5069130 or similar, calling JEditorPane.setPage(URL) can lead to a RuntimeException caused by a NullPointerException. JEditorPane should handle the problem internally and rethrow as an IOException.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expect an IOException to be thrown, caught, and ignored.
      ACTUAL -
      A RuntimeException (not a subclass of RuntimeException) is thrown.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
          Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.NullPointerException
           at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1014)
           at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2211)
           at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:382)
           at javax.swing.JEditorPane.getStream(JEditorPane.java:778)
           at javax.swing.JEditorPane.getStream(JEditorPane.java:792)
           at javax.swing.JEditorPane.setPage(JEditorPane.java:419)
           at javax.swing.JEditorPane.setPage(JEditorPane.java:923)
           at JEditorPaneBug7$1.run(JEditorPaneBug7.java:11)
           at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
           at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
           at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
           at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
           at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
           at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
          Caused by: java.lang.NullPointerException
           at sun.net.www.ParseUtil.toURI(ParseUtil.java:261)
           at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:795)
           at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726)
           at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049)
           at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
           ... 13 more


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;

      public class JEditorPaneBug7 {
        public static void main(String args[]) {
          SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                JEditorPane jep = new JEditorPane();
                     
                try {
                   // Same URL from bug 5069130.
                   jep.setPage("http://www.scielo.br/gmb.htm");
                }
                catch(java.io.IOException e) {
                }
              }
            });
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Catch the exception, examine it to be sure it is this problem, ignore it if it is, otherwise rethrow.

        Attachments

          Activity

            People

            • Assignee:
              peterz Peter Zhelezniakov (Inactive)
              Reporter:
              ryeung Roger Yeung (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: