-
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: the disposables tree set won't accept another Disposable with the same priority. #3170
Conversation
the same priority. Disposable TmNettyRemotingClient and RmNettyRemotingClient added by GlobalTransactionScanner have the same priority by default, so the RmNettyRemotingClient won't be closed gracefully during shutdown.
Codecov Report
@@ Coverage Diff @@
## develop #3170 +/- ##
=============================================
- Coverage 50.38% 50.32% -0.07%
+ Complexity 3117 3114 -3
=============================================
Files 594 594
Lines 19625 19644 +19
Branches 2438 2443 +5
=============================================
- Hits 9889 9885 -4
- Misses 8743 8763 +20
- Partials 993 996 +3
|
Codecov Report
@@ Coverage Diff @@
## develop #3170 +/- ##
=============================================
- Coverage 50.95% 50.90% -0.05%
Complexity 3205 3205
=============================================
Files 602 602
Lines 19815 19834 +19
Branches 2470 2475 +5
=============================================
Hits 10096 10096
- Misses 8707 8726 +19
Partials 1012 1012
|
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, great found.
} | ||
|
||
@Override | ||
public int compareTo(DisposablePriorityWrapper disposablePriorityWrapper) { | ||
return priority - disposablePriorityWrapper.priority; |
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.
use PriorityQueue to replace TreeSet will solve this problem once and forever. No need to add a "seqId" to fix the probem which is actually caused by TreeSet.
if (cmp == 0) { | ||
if (seqId > disposablePriorityWrapper.seqId) { | ||
cmp = 1; | ||
} else if (seqId < disposablePriorityWrapper.seqId) { | ||
cmp = -1; | ||
} else { | ||
cmp = 0; | ||
} | ||
} |
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.
Long.compare(x, y) ?
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.
+1
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + priority; | ||
result = prime * result + (int) (seqId ^ (seqId >>> 32)); | ||
return result; |
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.
Objects.hash(...values)?
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.
+1
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
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + priority; | ||
result = prime * result + (int) (seqId ^ (seqId >>> 32)); | ||
return result; |
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.
+1
if (cmp == 0) { | ||
if (seqId > disposablePriorityWrapper.seqId) { | ||
cmp = 1; | ||
} else if (seqId < disposablePriorityWrapper.seqId) { | ||
cmp = -1; | ||
} else { | ||
cmp = 0; | ||
} | ||
} |
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.
+1
… the same priority (apache#3170)
Fix the following issue:
Disposable TmNettyRemotingClient and RmNettyRemotingClient added by GlobalTransactionScanner have the same priority by default, so the RmNettyRemotingClient won't be closed gracefully during shutdown.