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

victory pushed a commit to branch 2.7.3-release
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/2.7.3-release by this push:
     new 27789ce  duplicate decrease for ExecuteLimitFilter onError (#4380)
27789ce is described below

commit 27789cef6b3bf04ffa60140a4fdd3eaaf0358214
Author: ken.lj <ken.lj...@gmail.com>
AuthorDate: Thu Jun 27 11:14:13 2019 +0800

    duplicate decrease for ExecuteLimitFilter onError (#4380)
---
 .../src/main/java/org/apache/dubbo/rpc/RpcException.java   |  7 +++++++
 .../org/apache/dubbo/rpc/filter/ActiveLimitFilter.java     | 14 +++++++++++++-
 .../org/apache/dubbo/rpc/filter/ExecuteLimitFilter.java    | 13 ++++++++++---
 3 files changed, 30 insertions(+), 4 deletions(-)

diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcException.java 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcException.java
index dc8a1b4..88e5ee4 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcException.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcException.java
@@ -16,6 +16,8 @@
  */
 package org.apache.dubbo.rpc;
 
+import javax.naming.LimitExceededException;
+
 /**
  * RPC Exception. (API, Prototype, ThreadSafe)
  *
@@ -33,6 +35,7 @@ public /**final**/ class RpcException extends 
RuntimeException {
     public static final int FORBIDDEN_EXCEPTION = 4;
     public static final int SERIALIZATION_EXCEPTION = 5;
     public static final int NO_INVOKER_AVAILABLE_AFTER_FILTER = 6;
+    public static final int LIMIT_EXCEEDED_EXCEPTION = 7;
     private static final long serialVersionUID = 7815426752583648734L;
     /**
      * RpcException cannot be extended, use error code for exception type to 
keep compatibility
@@ -106,4 +109,8 @@ public /**final**/ class RpcException extends 
RuntimeException {
     public boolean isNoInvokerAvailableAfterFilter() {
         return code == NO_INVOKER_AVAILABLE_AFTER_FILTER;
     }
+
+    public boolean isLimitExceed() {
+        return code == LIMIT_EXCEEDED_EXCEPTION || getCause() instanceof 
LimitExceededException;
+    }
 }
\ No newline at end of file
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java
 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java
index 19090c1..27aa1f5 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java
@@ -72,7 +72,11 @@ public class ActiveLimitFilter extends ListenableFilter {
                     long elapsed = System.currentTimeMillis() - start;
                     remain = timeout - elapsed;
                     if (remain <= 0) {
-                        throw new RpcException("Waiting concurrent invoke 
timeout in client-side for service:  " + invoker.getInterface().getName() + ", 
method: " + invocation.getMethodName() + ", elapsed: " + elapsed + ", timeout: 
" + timeout + ". concurrent invokes: " + rpcStatus.getActive() + ". max 
concurrent invoke limit: " + max);
+                        throw new 
RpcException(RpcException.LIMIT_EXCEEDED_EXCEPTION,
+                                "Waiting concurrent invoke timeout in 
client-side for service:  " +
+                                        invoker.getInterface().getName() + ", 
method: " + invocation.getMethodName() +
+                                        ", elapsed: " + elapsed + ", timeout: 
" + timeout + ". concurrent invokes: " +
+                                        rpcStatus.getActive() + ". max 
concurrent invoke limit: " + max);
                     }
                 }
             }
@@ -100,6 +104,12 @@ public class ActiveLimitFilter extends ListenableFilter {
             URL url = invoker.getUrl();
             int max = invoker.getUrl().getMethodParameter(methodName, 
ACTIVES_KEY, 0);
 
+            if (t instanceof RpcException) {
+                RpcException rpcException = (RpcException)t;
+                if (rpcException.isLimitExceed()) {
+                    return;
+                }
+            }
             RpcStatus.endCount(url, methodName, getElapsed(invocation), false);
             notifyFinish(RpcStatus.getStatus(url, methodName), max);
         }
@@ -116,5 +126,7 @@ public class ActiveLimitFilter extends ListenableFilter {
                 }
             }
         }
+
+
     }
 }
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ExecuteLimitFilter.java
 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ExecuteLimitFilter.java
index e1af529..cf33311 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ExecuteLimitFilter.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ExecuteLimitFilter.java
@@ -52,9 +52,10 @@ public class ExecuteLimitFilter extends ListenableFilter {
         String methodName = invocation.getMethodName();
         int max = url.getMethodParameter(methodName, EXECUTES_KEY, 0);
         if (!RpcStatus.beginCount(url, methodName, max)) {
-            throw new RpcException("Failed to invoke method " + 
invocation.getMethodName() + " in provider " +
-                    url + ", cause: The service using threads greater than 
<dubbo:service executes=\"" + max +
-                    "\" /> limited.");
+            throw new RpcException(RpcException.LIMIT_EXCEEDED_EXCEPTION,
+                    "Failed to invoke method " + invocation.getMethodName() + 
" in provider " +
+                            url + ", cause: The service using threads greater 
than <dubbo:service executes=\"" + max +
+                            "\" /> limited.");
         }
 
         invocation.setAttachment(EXECUTELIMIT_FILTER_START_TIME, 
String.valueOf(System.currentTimeMillis()));
@@ -77,6 +78,12 @@ public class ExecuteLimitFilter extends ListenableFilter {
 
         @Override
         public void onError(Throwable t, Invoker<?> invoker, Invocation 
invocation) {
+            if (t instanceof RpcException) {
+                RpcException rpcException = (RpcException)t;
+                if (rpcException.isLimitExceed()) {
+                    return;
+                }
+            }
             RpcStatus.endCount(invoker.getUrl(), invocation.getMethodName(), 
getElapsed(invocation), false);
         }
 

Reply via email to