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 356a2f5  cache service key (#4255)
356a2f5 is described below

commit 356a2f5df25c9ec647447b9e6bdcb9a3395688c3
Author: ken.lj <[email protected]>
AuthorDate: Wed Jun 5 17:57:50 2019 +0800

    cache service key (#4255)
---
 .../src/main/java/org/apache/dubbo/common/URL.java    | 19 ++++++++++++++-----
 .../dubbo/rpc/protocol/thrift/ThriftCodecTest.java    |  4 ++--
 2 files changed, 16 insertions(+), 7 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 38008b6..4062641 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
@@ -128,6 +128,10 @@ class URL implements Serializable {
 
     private volatile transient String string;
 
+    private final transient String serviceKey;
+
+    private final transient String serviceInterface;
+
     protected URL() {
         this.protocol = null;
         this.username = null;
@@ -137,6 +141,8 @@ class URL implements Serializable {
         this.path = null;
         this.parameters = null;
         this.methodParameters = null;
+        this.serviceKey = null;
+        this.serviceInterface = null;
     }
 
     public URL(String protocol, String host, int port) {
@@ -210,6 +216,13 @@ class URL implements Serializable {
         }
         this.parameters = Collections.unmodifiableMap(parameters);
         this.methodParameters = Collections.unmodifiableMap(methodParameters);
+
+        this.serviceInterface = getParameter(INTERFACE_KEY, path);
+        if (this.serviceInterface == null) {
+            this.serviceKey = null;
+        } else {
+            this.serviceKey = buildKey(serviceInterface, 
getParameter(GROUP_KEY), getParameter(VERSION_KEY));
+        }
     }
 
     /**
@@ -1443,11 +1456,7 @@ class URL implements Serializable {
      * @return
      */
     public String getServiceKey() {
-        String inf = getServiceInterface();
-        if (inf == null) {
-            return null;
-        }
-        return buildKey(inf, getParameter(GROUP_KEY), 
getParameter(VERSION_KEY));
+        return serviceKey;
     }
 
     /**
diff --git 
a/dubbo-rpc/dubbo-rpc-thrift/src/test/java/org/apache/dubbo/rpc/protocol/thrift/ThriftCodecTest.java
 
b/dubbo-rpc/dubbo-rpc-thrift/src/test/java/org/apache/dubbo/rpc/protocol/thrift/ThriftCodecTest.java
index a8c66a7..36fbe6c 100644
--- 
a/dubbo-rpc/dubbo-rpc-thrift/src/test/java/org/apache/dubbo/rpc/protocol/thrift/ThriftCodecTest.java
+++ 
b/dubbo-rpc/dubbo-rpc-thrift/src/test/java/org/apache/dubbo/rpc/protocol/thrift/ThriftCodecTest.java
@@ -133,7 +133,7 @@ public class ThriftCodecTest {
 
         Request request = createRequest();
 
-        DefaultFuture future = DefaultFuture.newFuture(channel, request, 10);
+        DefaultFuture future = DefaultFuture.newFuture(channel, request, 10, 
null);
 
         TMessage message = new TMessage("echoString", TMessageType.REPLY, 
ThriftCodec.getSeqId());
 
@@ -210,7 +210,7 @@ public class ThriftCodecTest {
 
         Request request = createRequest();
 
-        DefaultFuture future = DefaultFuture.newFuture(channel, request, 10);
+        DefaultFuture future = DefaultFuture.newFuture(channel, request, 10, 
null);
 
         TMessage message = new TMessage("echoString", TMessageType.EXCEPTION, 
ThriftCodec.getSeqId());
 

Reply via email to