Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 311554 - ShutdownThread.deregister(this) in Server.doStop causes IllegalStateException at shutdown
Summary: ShutdownThread.deregister(this) in Server.doStop causes IllegalStateException...
Status: RESOLVED FIXED
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 7.0.2.RC0   Edit
Assignee: Greg Wilkins CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 312526
  Show dependency tree
 
Reported: 2010-05-04 10:09 EDT by Eirik Bjørsnøs CLA
Modified: 2010-05-14 02:44 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eirik Bjørsnøs CLA 2010-05-04 10:09:55 EDT
Build Identifier: 


Problem:

I have my own shutdown hook registered that calls Server.stop() Server.doStop calls ShutDownThread.deregister which ends up calling Runtime.addShutdownHook in ShutdownThread's constructor.

Runtime.addShutdownHook then causes an IllegalStateException because shutdown is already in progress:

java.lang.IllegalStateException: Shutdown in progress
        at java.lang.Shutdown.add(Shutdown.java:81)
        at java.lang.Runtime.addShutdownHook(Runtime.java:190)
        at org.eclipse.jetty.util.thread.ShutdownThread.<init>(ShutdownThread.java:48)
        at org.eclipse.jetty.util.thread.ShutdownThread.<clinit>(ShutdownThread.java:36)
        at org.eclipse.jetty.server.Server.doStop(Server.java:315)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:80)


Solution:

ShutDownThread.deregister in Server.doStop should probably be protected by an if(getStopAtShutdown()) as is ShutdownThread.register in doStart().


Reproducible: Always

Steps to Reproduce:
1. Create and register a custom shutdown thread that will call Server.stop
2. Start server
3.  Stop server
4. Observe stacktrace.
Comment 1 Greg Wilkins CLA 2010-05-05 09:07:18 EDT
Fixed thanks!

r1772