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

Using HttpUrlConnection + ShowDocument in applet = hang java in ie7

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • None
    • 6u15
    • deploy
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_15"
      Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
      Java HotSpot(TM) Client VM (build 14.1-b02, mixed mode, sharing)

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

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Internet Explorer 7.0.5730.11

      Also reproduced on windows vista with ie7

      A DESCRIPTION OF THE PROBLEM :
      This bug is in Internet explorer only. Not Mozilla firefox 3.5

      I have an applet that uses URLConnection to load data from a webserver. (URLConnection uses HttpURLConnection). It also uses showDocument from Applet context to move to new URL's that also contain applets. When I call showDocument it regularly happens that the new page loads, and the applet part only shows the loading animation. A trace reveals that the program is hung on getting a proxy:

      "AWT-EventQueue-3" prio=4 tid=0x02a73800 nid=0x284 in Object.wait() [0x041df000]
         java.lang.Thread.State: WAITING (on object monitor)
      at java.lang.Object.wait(Native Method)
      at sun.plugin2.message.Queue.waitForMessage(Unknown Source)
      - locked <0x230a1ae8> (a sun.plugin2.message.Queue)
      at sun.plugin2.message.Pipe.receive(Unknown Source)
      at sun.plugin2.main.client.MessagePassingExecutionContext.getProxyList(Unknown Source)
      at sun.plugin2.main.client.PluginProxySelector.select(Unknown Source)
      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
      at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
      <snip>

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create an applet that in the init method code loads something of the web with URLConnection and make a button that when pressed, loads its own html page again

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Open a new html page with working applet
      ACTUAL -
      Opens a new Html page with an applet that is waiting for something indefinately

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No crash

      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- BEGIN SOURCE ----------
      ==applet code==
      package viers.gui;

      import java.awt.BorderLayout;
      import java.io.InputStream;
      import java.net.URL;
      import java.net.URLConnection;

      import javax.swing.JPanel;
      import javax.swing.JApplet;
      import javax.swing.JButton;

      public class HangTest extends JApplet {

      private static final long serialVersionUID = 1L;
      private JPanel jContentPane = null;
      private JButton move = null;

      public void init() {
           try {
                  javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
                      public void run() {
                       loadDoc();
                       setContentPane(getJContentPane());
                      }
                  });
              } catch (Exception e) {
                  System.err.println("createGUI didn't successfully complete");
              }
      }


      private void loadDoc(){
      try {
      URL url = new URL("http://www.google.nl");
      URLConnection con = url.openConnection();
      InputStream is = con.getInputStream();
      try{
      } finally {
      is.close();
      }
      } catch (Exception e) {
      e.printStackTrace();
      }
      }

      private JPanel getJContentPane() {
      if (jContentPane == null) {
      jContentPane = new JPanel();
      jContentPane.setLayout(new BorderLayout());
      jContentPane.add(getMove(), BorderLayout.CENTER);
      }
      return jContentPane;
      }

      private JButton getMove() {
      if (move == null) {
      move = new JButton();
      move.setText("test");
      move.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent e) {
      getAppletContext().showDocument(getDocumentBase());
      }
      });
      }
      return move;
      }

      }

      ==html code==
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html>
       <head>
        <title>HangTest</title>
       </head>
       <body>
      <div style='height: 600px; width: 100%; margin:0; padding:0; border:0'>
      <applet code='viers.gui.HangTest.class' archive='documents.jar' width='100%' height='100%'>
      </applet>
      </div>
       </body>
      </html>

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

      CUSTOMER SUBMITTED WORKAROUND :
      Disable plugin 2 and use classic plugin.

            herrick Andy Herrick (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: