-
Notifications
You must be signed in to change notification settings - Fork 3.8k
callbacks registered to Log4jShutdown is not executed when stop is called #2133
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -232,22 +232,22 @@ public void run() | |
| Injector injector = makeInjector(); | ||
| try { | ||
| final Lifecycle lifecycle = initLifecycle(injector); | ||
| Runtime.getRuntime().addShutdownHook( | ||
| new Thread( | ||
| new Runnable() | ||
| { | ||
| @Override | ||
| public void run() | ||
| { | ||
| log.info("Running shutdown hook"); | ||
| lifecycle.stop(); | ||
| } | ||
| } | ||
| ) | ||
| final Thread hook = new Thread( | ||
| new Runnable() | ||
| { | ||
| @Override | ||
| public void run() | ||
| { | ||
| log.info("Running shutdown hook"); | ||
| lifecycle.stop(); | ||
| } | ||
| } | ||
| ); | ||
| Runtime.getRuntime().addShutdownHook(hook); | ||
| injector.getInstance(ExecutorLifecycle.class).join(); | ||
| // Explicitly call lifecycle stop, dont rely on shutdown hook. | ||
| lifecycle.stop(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is using Thread now, can this simply call
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be. But if
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, hook.run() should call its Runnable.run() which calls lifecycle.stop(). But in the interest of minimizing changes for this PR such a change can be ignored for now. |
||
| Runtime.getRuntime().removeShutdownHook(hook); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO this is more appropriately solved by metamx/java-util#28
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not opposed to the changes in this file though, as it adds better future proofing of the shutdown process for peons |
||
| } | ||
| catch (Throwable t) { | ||
| log.error(t, "Error when starting up. Failing."); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be while(current == expected), wondering if we should return false if some other transition other than the expected happens ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw ISE with a note in the method signature would be appropriate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or return the state that was found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done