This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch performance-tuning-2.7.x
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/performance-tuning-2.7.x by 
this push:
     new 34e7871  check before calling getMethodParameter
34e7871 is described below

commit 34e787119303341505a008838ca0d14b14da3284
Author: ken.lj <ken.lj...@gmail.com>
AuthorDate: Tue Jun 4 18:07:16 2019 +0800

    check before calling getMethodParameter
---
 dubbo-common/src/main/java/org/apache/dubbo/common/URL.java   |  7 +++++++
 .../main/java/org/apache/dubbo/rpc/support/MockInvoker.java   | 11 +++++++----
 .../apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java |  8 ++++----
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java 
b/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java
index 741b7cb..38008b6 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java
@@ -1015,6 +1015,13 @@ class URL implements Serializable {
         return value != null && value.length() > 0;
     }
 
+    public boolean hasMethodParameter(String method) {
+        if (method == null) {
+            return false;
+        }
+        return getMethodParameters().containsKey(method);
+    }
+
     public boolean isLocalHost() {
         return NetUtils.isLocalHost(host) || getParameter(LOCALHOST_KEY, 
false);
     }
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockInvoker.java
 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockInvoker.java
index 90f4d69..2badc04 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockInvoker.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockInvoker.java
@@ -39,12 +39,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import static org.apache.dubbo.rpc.Constants.MOCK_KEY;
-import static org.apache.dubbo.rpc.Constants.RETURN_PREFIX;
-import static org.apache.dubbo.rpc.Constants.THROW_PREFIX;
 import static org.apache.dubbo.rpc.Constants.FAIL_PREFIX;
 import static org.apache.dubbo.rpc.Constants.FORCE_PREFIX;
+import static org.apache.dubbo.rpc.Constants.MOCK_KEY;
 import static org.apache.dubbo.rpc.Constants.RETURN_KEY;
+import static org.apache.dubbo.rpc.Constants.RETURN_PREFIX;
+import static org.apache.dubbo.rpc.Constants.THROW_PREFIX;
 
 final public class MockInvoker<T> implements Invoker<T> {
     private final static ProxyFactory PROXY_FACTORY = 
ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
@@ -95,10 +95,13 @@ final public class MockInvoker<T> implements Invoker<T> {
 
     @Override
     public Result invoke(Invocation invocation) throws RpcException {
-        String mock = getUrl().getParameter(invocation.getMethodName() + "." + 
MOCK_KEY);
         if (invocation instanceof RpcInvocation) {
             ((RpcInvocation) invocation).setInvoker(this);
         }
+        String mock = null;
+        if (getUrl().hasMethodParameter(invocation.getMethodName())) {
+            mock = getUrl().getParameter(invocation.getMethodName() + "." + 
MOCK_KEY);
+        }
         if (StringUtils.isBlank(mock)) {
             mock = getUrl().getParameter(MOCK_KEY);
         }
diff --git 
a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java
 
b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java
index c82599c..e151cb6 100644
--- 
a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java
+++ 
b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java
@@ -41,13 +41,13 @@ import static 
org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
-import static 
org.apache.dubbo.rpc.protocol.dubbo.Constants.CALLBACK_SERVICE_KEY;
 import static org.apache.dubbo.rpc.Constants.CALLBACK_INSTANCES_LIMIT_KEY;
 import static org.apache.dubbo.rpc.Constants.DEFAULT_CALLBACK_INSTANCES;
+import static org.apache.dubbo.rpc.Constants.IS_SERVER_KEY;
+import static 
org.apache.dubbo.rpc.protocol.dubbo.Constants.CALLBACK_SERVICE_KEY;
 import static 
org.apache.dubbo.rpc.protocol.dubbo.Constants.CALLBACK_SERVICE_PROXY_KEY;
-import static 
org.apache.dubbo.rpc.protocol.dubbo.Constants.IS_CALLBACK_SERVICE;
 import static 
org.apache.dubbo.rpc.protocol.dubbo.Constants.CHANNEL_CALLBACK_KEY;
-import static org.apache.dubbo.rpc.Constants.IS_SERVER_KEY;
+import static 
org.apache.dubbo.rpc.protocol.dubbo.Constants.IS_CALLBACK_SERVICE;
 
 /**
  * callback service helper
@@ -65,7 +65,7 @@ class CallbackServiceCodec {
     private static byte isCallBack(URL url, String methodName, int argIndex) {
         // parameter callback rule: method-name.parameter-index(starting from 
0).callback
         byte isCallback = CALLBACK_NONE;
-        if (url != null) {
+        if (url != null && url.hasMethodParameter(methodName)) {
             String callback = url.getParameter(methodName + "." + argIndex + 
".callback");
             if (callback != null) {
                 if (callback.equalsIgnoreCase("true")) {

Reply via email to