-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
Judge null for key and value in attachment in RpcContextFilter. #2171
Conversation
If not, NullPointerException will be thrown in RpcContextFilter in some case.
Codecov Report
@@ Coverage Diff @@
## master #2171 +/- ##
============================================
+ Coverage 54.3% 54.58% +0.28%
- Complexity 5111 5150 +39
============================================
Files 559 569 +10
Lines 24981 25036 +55
Branches 4453 4457 +4
============================================
+ Hits 13566 13666 +100
+ Misses 9380 9326 -54
- Partials 2035 2044 +9
Continue to review full report at Codecov.
|
if (StringUtils.isNotEmpty(value)) { | ||
if (illegalForRest(value)) { | ||
throw new IllegalArgumentException("The attachments of " + RpcContext.class.getSimpleName() + " must not contain ',' or '=' when using rest protocol"); | ||
} |
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.
if ( (StringUtils.isNotEmpty(key) && illegalForRest(key)) || (StringUtils.isNotEmpty(value) && illegalForRest(value)) ) {
throw new IllegalArgumentException("The attachments of " + RpcContext.class.getSimpleName() + " must not contain ',' or '=' when using rest protocol");
}
Is the above code better ?
* @return true for illegal | ||
*/ | ||
private boolean illegalForRest(String v) { | ||
return v.contains(",") || v.contains("="); |
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.
Or judge null place here ?
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.
Prefer judge null in 'illegalForRest'.
The meaning of this method is that if a value is not null, it should not contains ',' or '='.
I will fix this soon.
:)
LGTM. |
Judge null for key and value in attachment in RpcContextFilter.
If not, NullPointerException will be thrown in RpcContextFilter in some case.
Fix #2127 : #2127 (comment)