-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HDFS-16391. Avoid evaluation of LOG.debug statement in NameNodeHeartbeatService #3820
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
Conversation
|
💔 -1 overall
This message was automatically generated. |
| // block info available, HA status not expected | ||
| LOG.debug( | ||
| "Reporting non-HA namenode as operational: " + getNamenodeDesc()); | ||
| "Reporting non-HA namenode as operational: {}", getNamenodeDesc()); |
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.
I think this statement really needs wrapped in an if (LOG.isDebugEnabled()). The reason is that the method call getNamenodeDesc() needs to be evaluated whether we log or not, so its result can be passed into the LOG.debug() method. Inside LOG.debug, it will skip the logging, but by then, we have already formed the string inside getNamenodeDesc() and never use it.
If we are passing an object into LOG.debug, this change would be the correct thing to do, as toString() will only get called on the object if the log message is created. However when we pass a method call into the method, it needs to be evaluated first AFAIK.
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.
Note there is another debug message just above this one which looks similar and could be wrapped in a if LOG.isDebugEnabled at 270 for the same reason.
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.
Modified, please help review again. Thanks!
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.
The latest change looks good. Thanks for changing both the log lines.
sodonnel
left a comment
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.
LGTM, pending a good CI run.
|
💔 -1 overall
This message was automatically generated. |
680ec9a to
91c0892
Compare
|
💔 -1 overall
This message was automatically generated. |
…eatService
Description of PR
How was this patch tested?
For code changes:
LICENSE,LICENSE-binary,NOTICE-binaryfiles?JIRA:
https://issues.apache.org/jira/browse/HDFS-16391?filter=-2