JDK-6612928 : Win32ShellFolder2 throws RejectedExecutionException on application exit
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u10,7
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows,windows_xp
  • CPU: x86
  • Submitted: 2007-10-04
  • Updated: 2019-12-17
  • Resolved: 2019-12-17
Description
(copied from the original email)
-------- Original Message --------
Subject: [JAVA2D] Bizarre exception
Date: Fri, 28 Sep 2007 08:01:05 -0700
Wrom: RTNHGSWZIDREXCAXZOWCONEUQZAAFXISHJEXXIMQZU
Reply-To: ###@###.###
To: ###@###.###

Upon closing a perfectly ordinary program (a test JTable within
a scrollpane) running under Java 6 I got a flurry of

Exception while removing reference:
java.util.concurrent.RejectedExecutionException
java.util.concurrent.RejectedExecutionException
        at
java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1759)
        at
java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:767)
        at
java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:658)
        at
java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:92)
        at
sun.awt.shell.Win32ShellFolder2$ComTask.execute(Win32ShellFolder2.java:1214)
        at
sun.awt.shell.Win32ShellFolder2$FolderDisposer.dispose(Win32ShellFolder2.java:170)
        at sun.java2d.Disposer.run(Disposer.java:128)
        at java.lang.Thread.run(Thread.java:619)

Comments
EVALUATION This is still reproducible in 6u10. From the java2d mailing list: http://forums.java.net/jive/thread.jspa?threadID=31316&tstart=135 ---- I am developing a swing application that allows a client to save a graph (as JPEG or PNG) using the JFreeChart package. Only when I choose to write out a graph do I get an exception on program close. The stack trace I get is repeated a number of times: Exception while removing reference: java.util.concurrent.RejectedExecutionException Exception while removing reference: java.util.concurrent.RejectedExecutionException Exception while removing reference: java.util.concurrent.RejectedExecutionException Exception while removing reference: java.util.concurrent.RejectedExecutionException java.util.concurrent.RejectedExecutionException at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1760) at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:767) at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:658) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:92) at sun.awt.shell.Win32ShellFolderManager2$ComInvoker.invoke(Win32ShellFolderManager2.java:493) at sun.awt.shell.Win32ShellFolder2$FolderDisposer.dispose(Win32ShellFolder2.java:170) at sun.java2d.Disposer.run(Disposer.java:128) at java.lang.Thread.run(Thread.java:619) java.util.concurrent.RejectedExecutionException at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1760) at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:767) at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:658) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:92) at sun.awt.shell.Win32ShellFolderManager2$ComInvoker.invoke(Win32ShellFolderManager2.java:493) at sun.awt.shell.Win32ShellFolder2$FolderDisposer.dispose(Win32ShellFolder2.java:170) at sun.java2d.Disposer.run(Disposer.java:128) at java.lang.Thread.run(Thread.java:619) ---- Also, an apparent workaround: ---- I wasn't using that version but just updated and this did not solve the problem. I accidentally came across a fix for my program. Changing the close operation for my application to DISPOSE_ON_CLOSE instead of EXIT_ON_CLOSE caused the exception to disappear. ----
28-07-2008

EVALUATION Further investigation shows that just rejecting COM invocations after the executor shutdown is not a good idea, because it may cause native resource leak. We should rather change the strategy of handling FolderDisposers and ensure that their clean-up code will be invoked *before* the executor shutdown.
14-01-2008

EVALUATION Since 6u2 b01 we use the concurrent package to marshall COM calls to the dedicated thread. My investigation shows that this exception is thrown with a scenario like this: 1) user exits the application 2) the JVM starts invoking shutdown hooks 3) the COM thread's shutdown hook initiates shutdown of ThreadPoolExecutor 4) a new COM call is submitted from within another thread We should't accept any COM calls after the shutdown hook has been called.
04-10-2007