Skip to content

Commit

Permalink
fixes #9086 to solve race condition issue. (#9588)
Browse files Browse the repository at this point in the history
Fixes #9086 in master branch
  • Loading branch information
zrlw committed Jan 21, 2022
1 parent 8240ea2 commit 6c75300
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -325,9 +325,10 @@ public String getParameter(String key) {
}

public String getMethodParameter(String method, String key, String defaultValue) {
// set consumerMethodParams firstly to avoid NPE at race condition.
if (methodParams == null) {
methodParams = URL.toMethodParameters(params);
consumerMethodParams = URL.toMethodParameters(consumerParams);
methodParams = URL.toMethodParameters(params);
}

String value = getMethodParameter(method, key, consumerMethodParams);
Expand Down Expand Up @@ -359,12 +360,14 @@ public boolean hasMethodParameter(String method, String key) {
}

public boolean hasMethodParameter(String method) {
// set consumerMethodParams firstly to NPE at race condition.
if (methodParams == null) {
methodParams = URL.toMethodParameters(params);
consumerMethodParams = URL.toMethodParameters(consumerParams);
methodParams = URL.toMethodParameters(params);
}

return consumerMethodParams.containsKey(method) || methodParams.containsKey(method);
return (CollectionUtils.isNotEmptyMap(consumerMethodParams) && consumerMethodParams.containsKey(method))
|| (CollectionUtils.isNotEmptyMap(methodParams) && methodParams.containsKey(method));
}

public String toDescString() {
Expand Down

0 comments on commit 6c75300

Please sign in to comment.