JDK-6979541 : closed/javax/swing/plaf/basic/AWTEventListenerLeak/AWTEventListenerLeak.java fails
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux_redhat_5.0
  • CPU: x86
  • Submitted: 2010-08-24
  • Updated: 2011-03-07
  • Resolved: 2011-03-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b116Fixed
Related Reports
Relates :  
Description
Testsuite name: regression j2se
test: closed/javax/swing/plaf/basic/AWTEventListenerLeak/AWTEventListenerLeak.java
JDK/JRE tested: jdk 7 b106
OS/architecture: rhel5-x64
Reproducible: Always
Reproducible on machine: stt-57.russia
Is it a platform specific regression: N
Is it a Regression: N

Test run log location:
[stt-robot@stt-57]$ cat cur/work/closed/javax/swing/plaf/basic/AWTEventListenerLeak/AWTEventListenerLeak.jtr 
#Test Results (version 2)
#Tue Aug 24 19:45:48 MSD 2010
#checksum:308b8d2d0b3cccfb
#-----testdescription-----
$file=/net/vice/export/stt/newroot/regression/workspaces/170/1.7.0_fcsb106/j2se/test/closed/javax/swing/plaf/basic/AWTEventListenerLeak/AWTEventListenerLeak.java
$root=/net/vice/export/stt/newroot/regression/workspaces/170/1.7.0_fcsb106/j2se/test
author=bchristi
keywords=bug6264013 othervm
run=USER_SPECIFIED main/othervm AWTEventListenerLeak\n
source=AWTEventListenerLeak.java
title=Test BasicLookAndFeel.AWTEventHelper leak

#-----environment-----

#-----testresult-----
description=file:///net/vice/export/stt/newroot/regression/workspaces/170/1.7.0_fcsb106/j2se/test/closed/javax/swing/plaf/basic/AWTEventListenerLeak/AWTEventListenerLeak.java
end=Tue Aug 24 19:45:48 MSD 2010
environment=regtest
execStatus=Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Test Failed!
javatestOS=Linux 2.6.18-194.el5 (i386)
javatestVersion=3.2.2_03
script=com.sun.javatest.regtest.RegressionScript 
sections=script_messages build main
start=Tue Aug 24 19:45:47 MSD 2010
test=closed/javax/swing/plaf/basic/AWTEventListenerLeak/AWTEventListenerLeak.java
work=/export/JQA/regression/cur/work/closed/javax/swing/plaf/basic/AWTEventListenerLeak

#section:script_messages
----------messages:(4/186)----------
JDK under test: (/export/jdk/jdk1.7.0b106)
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b106)
Java HotSpot(TM) Client VM (build 19.0-b05, mixed mode, sharing)

#section:build
----------messages:(3/105)----------
command: build AWTEventListenerLeak
reason: Named class compiled on demand
elapsed time (seconds): 0.001
result: Passed. All files up to date

#section:main
----------messages:(3/135)----------
command: main AWTEventListenerLeak
reason: User specified action: run main/othervm AWTEventListenerLeak 
elapsed time (seconds): 0.934
----------System.out:(12/579)----------
TestFrame created on sun.awt.AppContext[threadGroup=system]
TestFrame created on sun.awt.AppContext[threadGroup=system]
TestFrame created on sun.awt.AppContext[threadGroup=createGroup 0]
TestFrame created on sun.awt.AppContext[threadGroup=system]
TestFrame created on sun.awt.AppContext[threadGroup=system]
TestFrame created on sun.awt.AppContext[threadGroup=system]
7 AppContexts
Now destroy everything
TestFrame.dispose()
Done disposing AppContexts.  Now count listeners
1 AWTEventListeners remain on the Toolkit: 
javax.swing.plaf.basic.BasicLookAndFeel$AWTEventHelper@eee36c
----------System.err:(13/709)----------
java.lang.RuntimeException: Test Failed!
	at AWTEventListenerLeak.main(AWTEventListenerLeak.java:128)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:613)
	at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:96)
	at java.lang.Thread.run(Thread.java:717)

JavaTest Message: Test threw exception: java.lang.RuntimeException: Test Failed!
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: java.lang.RuntimeException: Test Failed!
result: Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Test Failed!


test result: Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Test Failed!
Steps to reproduce: 
[stt-robot@stt-57]$ /export/jdk/jdk1.7.0b106/bin/java AWTEventListenerLeak      
TestFrame created on sun.awt.AppContext[threadGroup=createGroup 0]
TestFrame created on sun.awt.AppContext[threadGroup=system]
TestFrame created on sun.awt.AppContext[threadGroup=system]
TestFrame created on sun.awt.AppContext[threadGroup=system]
TestFrame created on sun.awt.AppContext[threadGroup=system]
TestFrame created on sun.awt.AppContext[threadGroup=system]
7 AppContexts
Now destroy everything
TestFrame.dispose()
Done disposing AppContexts.  Now count listeners
2 AWTEventListeners remain on the Toolkit: 
javax.swing.plaf.basic.BasicLookAndFeel$AWTEventHelper@fabe9
java.awt.LightweightDispatcher@112f614
Exception in thread "main" java.lang.RuntimeException: Test Failed!
	at AWTEventListenerLeak.main(AWTEventListenerLeak.java:128)

Comments
SUGGESTED FIX --- a/src/share/classes/sun/awt/SunToolkit.java Thu Sep 30 21:06:53 2010 +0400 +++ b/src/share/classes/sun/awt/SunToolkit.java Fri Oct 01 15:56:53 2010 +0400 @@ -313,6 +313,11 @@ */ public static AppContext createNewAppContext() { ThreadGroup threadGroup = Thread.currentThread().getThreadGroup(); + // Create appContext before initialization of EventQueue, so all + // the calls to AppContext.getAppContext() from EventQueue ctor + // return correct values + AppContext appContext = new AppContext(threadGroup); + EventQueue eventQueue; String eqName = System.getProperty("AWT.EventQueueClass", "java.awt.EventQueue"); @@ -322,7 +327,6 @@ System.err.println("Failed loading " + eqName + ": " + e); eventQueue = new EventQueue(); } - AppContext appContext = new AppContext(threadGroup); appContext.put(AppContext.EVENT_QUEUE_KEY, eventQueue); PostEventQueue postEventQueue = new PostEventQueue(eventQueue);
01-10-2010

EVALUATION This is a regression caused by the following change (part of the fix for 4913324): public EventQueue() { ... /* * ... * completes thus causing mess in thread group to appcontext mapping. */ + pushPopLock = (Lock)AppContext.getAppContext().get(AppContext.EVENT_QUEUE_LOCK_KEY); + pushPopCond = (Condition)AppContext.getAppContext().get(AppContext.EVENT_QUEUE_COND_KEY); } What really matters is the call to AppContext.getAppContext(): a new event queue is created from SunToolkit.createNewAppContext() before the new AppContext is initialized, so AppContext.getAppContext() returns (and remembers! as it caches the current context in AppContext.threadAppContext field) a wrong value. After SunToolkit.createNewAppContext() is done, AppContext.getAppContext(), which is used in the test and in BasicLookAndFeel, still returns an incorrect value (system AppContext instead of just created one). This leads to the leak.
01-10-2010

EVALUATION Possibly it is a regression after 4913324.
29-09-2010