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

EDT auto shutdown is broken in case of new event queue usage

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 8u45
    • client-libs
    • b83
    • x86
    • generic

        FULL PRODUCT VERSION :
        java version "1.8.0_45"
        Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
        Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Darwin unit-714.labs.intellij.net 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64

        A DESCRIPTION OF THE PROBLEM :
        The problem is that java application which runs in headless mode doesn't terminate on it's main thread completion under the circumstances below:
        * EventQueue.push(new EventQueue()) is called on a system EventQueue
        * an event is posted to the EventQueue

        ADDITIONAL REGRESSION INFORMATION:
        The same code works fine under os x java6:

        java version "1.6.0_65"
        Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
        Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Compile and run the application which code is provided above

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The application is successfully terminated
        ACTUAL -
        The application hangs

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Thread dump (relevant part - not-daemon thread):
        "AWT-EventQueue-0@563" prio=6 tid=0xe nid=NA waiting
          java.lang.Thread.State: WAITING
        at sun.misc.Unsafe.park(Unsafe.java:-1)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
        at java.awt.EventQueue.getNextEvent(EventQueue.java:554)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:170)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        package org;

        import java.awt.*;

        public class Xxx {
            public static void main(String[] args) throws Exception {
                System.setProperty("java.awt.headless", "true");
                final EventQueue systemQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
                // Current java process is successfully terminated if the line below is commented.
                systemQueue.push(new EventQueue());
                EventQueue.invokeAndWait(new Runnable() {
                    @Override
                    public void run() {
                        System.out.println("Activated EDT");
                    }
                });
                System.out.println("After EDT activation");
            }
        }

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

              alitvinov Anton Litvinov (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: