Skip to content

Commit

Permalink
Fixes apache#9086 again to solve race condition issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
zrlw committed Jan 18, 2022
1 parent 8240ea2 commit c80774c
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 c80774c

Please sign in to comment.