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

Modal dialog doesn't handle exceptions correctly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.4.0
    • Fix Version/s: 1.4.0
    • Component/s: client-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      beta3
    • CPU:
      x86
    • OS:
      windows_nt

      Description



      Name: biR10147 Date: 09/03/2001

      When an exception is thrown on EventDispatchThread from inside of show() method of a modal dialog, this dialog exits its show() method without hiding itself, and finishes secondary message loop. As a result, it causes an application hang when a modal dialog is displayed during drag and drop operations, even if we refuse to start secondary event loop and throw an exception instead. In JDK 1.3, throwing an exception on EventDispatchThread doesn't break secondary event loop and doesn't make show() method exit.

      Steps to reproduce:

      1. Compile and run the test case below.
      2. Press the "Show" button to make the modal dialog appear.
      3. Press the "Throw" button on the dialog to throw new RuntimeException.
      4. Watch "show() ended" message in the console indicating that the show() method has finished without disposing the dialog.
      5. Press the "Throw" button again to see the exception being thrown not from secondary event loop.

      ===================================================
      import java.awt.Button;
      import java.awt.Dialog;
      import java.awt.FlowLayout;
      import java.awt.Frame;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      public class DialogTest extends Frame {

          public DialogTest() {
              super();
              setSize(200, 100);
              setLocation(50, 50);
              setLayout(new FlowLayout());
              final Dialog dialog = new Dialog(this, true);
              dialog.setSize(150, 100);
              dialog.setLayout(new FlowLayout());
              Button closeButton = new Button("Close");
              Button throwButton = new Button("Throw");
              Button showButton = new Button("Show");
              closeButton.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      dialog.hide();
                  }
              });
              dialog.add(closeButton);
              throwButton.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      throw new RuntimeException("New exception");
                  }
              });
              dialog.add(throwButton);
              showButton.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      try {
                          dialog.show();
                      } finally {
                          System.out.println("show() finished");
                      }
                  }
              });
              add(showButton);
          }

          public static void main(String[] args) {
              (new DialogTest()).setVisible(true);
          }
      }
      ===================================================

      ###@###.###

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mmartaksunw Michael Martak (Inactive)
              Reporter:
              ibdsunw Ibd Ibd (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: