-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
bugfix: thread unsafe issue of MySQLKeywordChecker initialization #1599
Conversation
Potential race condition: this instance of `keywordChecker` is available to other threads before `keywordSet` are assign, which may causes NPE if other threads call '#check' method. Since `MySQLKeywordChecker` is singleton, the field `keywordSet` doesn't need to be static, the initialization of `keywordSet` can be moved to constructor, removing the additional initialization inside locking, which ensures thread safely.
Codecov Report
@@ Coverage Diff @@
## develop #1599 +/- ##
=============================================
+ Coverage 46.43% 46.43% +<.01%
- Complexity 1713 1714 +1
=============================================
Files 350 350
Lines 12827 12828 +1
Branches 1615 1615
=============================================
+ Hits 5956 5957 +1
Misses 6224 6224
Partials 647 647
Continue to review full report at Codecov.
|
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!LGTM.
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! LGTM
MySQLKeywordChecker
Potential race condition: this instance of
keywordChecker
is available to other threads beforekeywordSet
are assign, which may causes NPE if other threads call '#check' method.Below is code segment (the code comment is added by me):
Since
MySQLKeywordChecker
is singleton, the fieldkeywordSet
doesn't need to be static,the initialization of
keywordSet
can be moved to constructor, removing the additional initialization inside locking, which ensures thread safely.