-
Notifications
You must be signed in to change notification settings - Fork 907
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
Fix TimedRunnable log NPE #4425
Conversation
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.
Good catch!
One note about perf implications of the change
|
||
TimedRunnable(Runnable runnable) { | ||
this.runnable = runnable; | ||
this.initNanos = MathUtils.nowInNano(); | ||
this.runnableString = runnable.toString(); |
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.
toString() can be expensive; maybe skip this and only log the class?
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.
Nice suggestion. Updated @dlg99
(cherry picked from commit 43b5ccc)
Descriptions of the changes in this PR:
Motivation
When the
ReadEntryProcessor
runs slow, theTimedRunnable
will print the warn log like below:bookkeeper/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedExecutor.java
Lines 197 to 208 in fd2c7c6
However we found that NPE happened in this log:
The root cause is that the
ReadEntryProcessor
will be recycled after callingrun
method, which means we shouldn't call any method of theReadEntryProcessor
after callingReadEntryProcessor#run()
. So line206 callingtoString()
method ofrunnable
(ReadEntryProcessor
) will cause NPE or any other wrong message.Changes
Save runnable string name and class when create
TimedRunnable
andTimedCallable