fix a potential NPE in CallbackServiceCodec.java#5768
Merged
chickenlj merged 1 commit intoapache:masterfrom Mar 13, 2020
Merged
fix a potential NPE in CallbackServiceCodec.java#5768chickenlj merged 1 commit intoapache:masterfrom
chickenlj merged 1 commit intoapache:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5768 +/- ##
============================================
+ Coverage 61.42% 61.45% +0.03%
+ Complexity 498 497 -1
============================================
Files 979 979
Lines 38828 38875 +47
Branches 5569 5604 +35
============================================
+ Hits 23851 23892 +41
- Misses 12360 12367 +7
+ Partials 2617 2616 -1
Continue to review full report at Codecov.
|
Contributor
|
Can you give one case that the URL can be null? |
Contributor
Author
|
I'm not sure whether the url is always not null. But I found that there already exists a null check for the url before setting the variable named group in this method. So I thought one more null check for this url is still needed before calling its getParameters method anyway. /**
* export or unexport callback service on client side
*
* @param channel
* @param url
* @param clazz
* @param inst
* @param export
* @throws IOException
*/
@SuppressWarnings({"unchecked", "rawtypes"})
private static String exportOrUnexportCallbackService(Channel channel, URL url, Class clazz, Object inst, Boolean export) throws IOException {
int instid = System.identityHashCode(inst);
Map<String, String> params = new HashMap<>(3);
// no need to new client again
params.put(IS_SERVER_KEY, Boolean.FALSE.toString());
// mark it's a callback, for troubleshooting
params.put(IS_CALLBACK_SERVICE, Boolean.TRUE.toString());
String group = (url == null ? null : url.getParameter(GROUP_KEY));
if (group != null && group.length() > 0) {
params.put(GROUP_KEY, group);
}
// add method, for verifying against method, automatic fallback (see dubbo protocol)
params.put(METHODS_KEY, StringUtils.join(Wrapper.getWrapper(clazz).getDeclaredMethodNames(), ","));
Map<String, String> tmpMap = new HashMap<>(url.getParameters()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What is the purpose of the change
Fix a potential NPE in CallbackServiceCodec.java
Brief changelog
Add a null check for url and parameters.
Follow this checklist to help us incorporate your contribution quickly and easily:
[Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.mvn clean install -DskipTests=false&mvn clean test-compile failsafe:integration-testto make sure unit-test and integration-test pass.