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

ZOOKEEPER-4515: ZK Cli quit command always logs error #1856

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1284,10 +1284,11 @@ public void run() {
} catch (Throwable e) {
if (closing) {
// closing so this is expected
LOG.warn(
"An exception was thrown while closing send thread for session 0x{}.",
Long.toHexString(getSessionId()),
e);
if (LOG.isDebugEnabled()) {
LOG.debug(
"An exception was thrown while closing send thread for session 0x{}.",
Long.toHexString(getSessionId()), e);
}
Comment on lines +1287 to +1291
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC LOG.debug already contains a call to LOG.isDebugEnabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a core code flow. So for me it is ok to go either way.
I have put debug enable check to void unnecessary toHexString call.
shall we keep as it is or shall it change it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your explanation. Then we can keep as is.

break;
} else {
LOG.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,27 @@ private ServiceUtils() {
*/
@SuppressFBWarnings("DM_EXIT")
public static final Consumer<Integer> SYSTEM_EXIT = (code) -> {
LOG.error("Exiting JVM with code {}", code);
arshadmohammad marked this conversation as resolved.
Show resolved Hide resolved
String msg = "Exiting JVM with code {}";
if (code == 0) {
// JVM exits normally
LOG.info(msg, code);
} else {
// JVM exits with error
LOG.error(msg, code);
}
System.exit(code);
};

/**
* No-op strategy, useful for tests.
*/
public static final Consumer<Integer> LOG_ONLY = (code) -> {
LOG.error("Fatal error, JVM should exit with code {}. "
if (code != 0) {
LOG.error("Fatal error, JVM should exit with code {}. "
+ "Actually System.exit is disabled", code);
} else {
LOG.info("JVM should exit with code {}. Actually System.exit is disabled", code);
}
};

private static volatile Consumer<Integer> systemExitProcedure = SYSTEM_EXIT;
Expand Down