Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully handle calls to DefaultPauseDetectorWrapper#retain during shutdown. #1884

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Gracefully handle calls to DefaultPauseDetectorWrapper#retain during …
…shutdown.
craftmaster2190 committed Oct 20, 2021
commit 81fafd35b4c49ce3ea0375cf70200c2a300c85d1
Original file line number Diff line number Diff line change
@@ -416,7 +416,16 @@ public void run() {
};

this.pauseDetector = pauseDetector;
Runtime.getRuntime().addShutdownHook(shutdownHook);
try {
Runtime.getRuntime().addShutdownHook(shutdownHook);
} catch (IllegalStateException ignored) {
// Do not interfere with ongoing shutdown
// java.lang.IllegalStateException: Shutdown in progress
InternalLogger instance = InternalLoggerFactory.getInstance(getClass());
instance.warn("Initialized PauseDetectorWrapper during shutdown; pause detector was shutdown immediately.");
// The JVM invokes shutdown hooks in non-deterministic order, so an existing pauseDetector might already be shutdown anyway
pauseDetector.shutdown();
}
} finally {
lock.unlock();
}
@@ -441,7 +450,7 @@ public void release() {

try {
Runtime.getRuntime().removeShutdownHook(shutdownHook);
} catch (IllegalStateException e) {
} catch (IllegalStateException ignored) {
// Do not prevent shutdown
// java.lang.IllegalStateException: Shutdown in progress
}