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

addShutdownHook fails if called after shutdown has commenced.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7
    • 6u17, 7
    • core-libs
    • b55
    • 7
    • b58
    • generic, sparc
    • generic, solaris_10

      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)

            mchung Mandy Chung (Inactive)
            mchung Mandy Chung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: