Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Prevent re-entrant execution of finalizers #10602
Prevent re-entrant execution of finalizers #10602
Changes from all commits
20001fb
d40caa1
9977a56
0cc2288
3c23421
8ad8117
105bf72
7082e49
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
request
is guaranteed to be non-null at this point?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.
It should be non-
null
. To get into thisprocess
method, a call to submitThreadLocal must be made and it assigns therequest
.The
request
is only assigned back tonull
in this method, just beforereturn
- after this check.E.g. unless there is some re-entrant invocation of the
process
method (it was there, but I hopefully fixed it),request
shall not benull
at this point.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.
Yes, I can see that gets set there along with adding to
pendingItems
. But it wasn't obvious thatperform
can't be called with an emptypendingItems
and then it would crash.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.
Shall we maybe include an assert at least?
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.
What's a difference between
NullPointerException
andAssertionError
?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.
Usually the NPE can be delayed and happen somewhere down the line, making debugging harder.
In this case I guess you are right - no meaningful difference. I just don't like NPEs so that was by habit :)
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.
Here is the submitThreadLocal javadoc.
Right now, when we run single threaded, one thread will pick the action. In the future, multiple threads may execute the
perform
method. In such situation the request may actually become null for some (slower) threads.The
ProcessItems
constructor marks theThreadLocalAction
as recurring to make sure some thread will pick our action up.ThreadLocalAction javadoc is also available.
Yes, we want asynchronous action, as we only want to run the action on a single thread. We don't care about others.
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.
Continues at the next PR.