JDK-6829503 : addShutdownHook fails if called after shutdown has commenced.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6u17,7
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,solaris_10
  • CPU: generic,sparc
  • Submitted: 2009-04-13
  • Updated: 2010-08-26
  • Resolved: 2009-05-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 b58Fixed
Related Reports
Relates :  
Description
If you call addShutdownHook after shutdown has already started, you should get IllegalStateException, as specified. If the call to addShutdownHook is the first one in this JDK, you will get an ExceptionInInitializerError instead, as below:

Exception in thread "main" java.lang.ExceptionInInitializerError
	at java.lang.Runtime.addShutdownHook(Runtime.java:209)
	at java.util.logging.LogManager.<init>(LogManager.java:246)
	at java.util.logging.LogManager$1.run(LogManager.java:194)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.util.logging.LogManager.<clinit>(LogManager.java:175)
	at LoggingDeadlock2$JavaChild.main(LoggingDeadlock2.java:106)
Caused by: java.lang.IllegalStateException: Shutdown in progress
	at java.lang.Shutdown.add(Shutdown.java:77)
	at java.lang.ApplicationShutdownHooks.<clinit>(ApplicationShutdownHooks.java:39)

Comments
EVALUATION Changeset: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/164ce9ff8b58
27-04-2009

EVALUATION Approved for M3.
23-04-2009

EVALUATION http://cr.openjdk.java.net/~mchung/6829503/webrev.01 request for M3 approval to fix a regression.
21-04-2009

EVALUATION A regression caused by the fix for 6810254. ApplicationShutdownHooks.<clinit> may fail to add the shutdown hook if shutdown is in progress. Need to handle this exception case.
13-04-2009