-
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: fix the NPE and reduce the request when lockkey is null #2495
Conversation
|
||
checkLock(context.buildLockKeys()); | ||
Set<String> lockKeys = context.getLockKeysBuffer(); | ||
if (CollectionUtils.isNotEmpty(lockKeys)) { |
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.
Is it more appropriate to put logic with lockkey as empty in the checkLock method?
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.
ok,i will change
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.
Codecov Report
@@ Coverage Diff @@
## develop #2495 +/- ##
=============================================
- Coverage 51.45% 51.42% -0.03%
+ Complexity 2666 2664 -2
=============================================
Files 529 529
Lines 16956 16964 +8
Branches 2051 2052 +1
=============================================
Hits 8724 8724
- Misses 7408 7412 +4
- Partials 824 828 +4
|
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
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
@@ -153,6 +153,9 @@ protected Locker getLocker() { | |||
Long branchID) { | |||
List<RowLock> locks = new ArrayList<RowLock>(); | |||
|
|||
if (StringUtils.isEmpty(lockKey)) { | |||
return null; | |||
} |
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.
Incorrect
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.
check isLockable
method.
@@ -153,6 +153,9 @@ protected Locker getLocker() { | |||
Long branchID) { | |||
List<RowLock> locks = new ArrayList<RowLock>(); | |||
|
|||
if (StringUtils.isEmpty(lockKey)) { |
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.
That s ok. And I think can remove the code
if (StringUtils.isNullOrEmpty(lockKey)) {
// no lock
return true;
}
at
acquireLock(BranchSession branchSession)
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
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
Ⅰ. Describe what this PR did
1.fix: Fix the NPE when lockkey is null;
2.optimize: Reduce once db request when lockkey is null;
Ⅱ. Does this pull request fix one issue?
yes.
issue
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews