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

REGRESSION: JOptionPane called concurrently still hangs in 1.4.2

XMLWordPrintable

    • b38
    • x86
    • windows_xp

      Name: gm110360 Date: 03/31/2004


      FULL PRODUCT VERSION :
      java version "1.4.2_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
      Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)

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

      A DESCRIPTION OF THE PROBLEM :
      When JOptionPane.showMessageDialog() is called concurrently from different threads, it tends to hang when one call quickly succeeds another. In this case, the OK button is not functional, and the only working button on the dialog is the close button. This and similar problems have been described previously in many other bug reports (e.g. 4834687, which is marked as a duplicate of 4531693, which is marked as fixed in mantis/1.4.2). However, the problem is not fixed in that release.

      Considering the unpredictability of this problem (it could hit anyone at the worst time) and the fact that it has been around for a long time with failed fixing attempts, eliminating it should be given a high priority. And eliminating at this point should mean truly fixing it and not just saying "can't reproduce anymore in release 1.4.2, so considering it fixed" as I have seen in another related bug report.

      This bug is a regression from 1.3.1_09. I can't reproduce it in that release.

      By the way, the bug submission web form is broken: the field indicating the regression version is too narrow on Internet Explorer, so I can't see what value I am choosing.

      I have seen discussions about whether it is legal to call JOptionPane.showMessageDialog() from threads other than the event dispatch thread. The API documentation for JOptionPane says:

      All dialogs are modal. Each showXxxDialog method blocks the current thread until the user's interaction is complete.

      This indicates that it is legal to call the method from threads other than the event thread.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      I attached some code to reproduce it. I have been able to reproduce it with just two concurrent threads, but you have to try many times. In this version with 20 threads, just close the dialogs by clicking the ok button. In some cases, clicking ok shouldn't work. Just try a couple of times. It may be easier to reproduce on a faster machine. Try increasing the number from 20 if it's hard to reproduce.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      This program opens 20 JOptionPane dialogs. All of them should be closable with the OK button, one after another.
      ACTUAL -
      On some of the opened dialogs, the ok button tends to not work when they have the focus. Only the close button works.

      REPRODUCIBILITY :
      This bug can be reproduced often.

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

      public final class JOptionPaneBug {
        
        private static final class OPRun implements Runnable {
          public void run() {
            JOptionPane.showMessageDialog(null, "Click OK");
          }
        }

        public static void main(String[] args) throws InterruptedException {
          for(int i = 0; i < 20; i++) {
            new Thread(new OPRun()).start();
          }
        }
      }

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

      Release Regression From : 1.3.1_11
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Incident Review ID: 237048)
      ======================================================================

            art Artem Ananiev (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: