You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2023/10/18 03:52:51 UTC

[dubbo] branch 3.2 updated: Only throws exception when exporting service (#13217)

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

albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.2 by this push:
     new fa11b68a16 Only throws exception when exporting service (#13217)
fa11b68a16 is described below

commit fa11b68a16a550ed19bb263d2f3ecd6d20a5fb8d
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Wed Oct 18 11:52:46 2023 +0800

    Only throws exception when exporting service (#13217)
---
 .../dubbo/qos/protocol/QosProtocolWrapper.java     | 23 +++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/protocol/QosProtocolWrapper.java b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/protocol/QosProtocolWrapper.java
index fe47762a33..2a6dfeff60 100644
--- a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/protocol/QosProtocolWrapper.java
+++ b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/protocol/QosProtocolWrapper.java
@@ -75,13 +75,13 @@ public class QosProtocolWrapper implements Protocol, ScopeModelAware {
 
     @Override
     public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {
-        startQosServer(invoker.getUrl());
+        startQosServer(invoker.getUrl(), true);
         return protocol.export(invoker);
     }
 
     @Override
     public <T> Invoker<T> refer(Class<T> type, URL url) throws RpcException {
-        startQosServer(url);
+        startQosServer(url, false);
         return protocol.refer(type, url);
     }
 
@@ -96,7 +96,7 @@ public class QosProtocolWrapper implements Protocol, ScopeModelAware {
         return protocol.getServers();
     }
 
-    private void startQosServer(URL url) throws RpcException {
+    private void startQosServer(URL url, boolean isServer) throws RpcException {
         boolean qosCheck = url.getParameter(QOS_CHECK, false);
 
         try {
@@ -134,13 +134,18 @@ public class QosProtocolWrapper implements Protocol, ScopeModelAware {
 
         } catch (Throwable throwable) {
             logger.warn(QOS_FAILED_START_SERVER, "", "", "Fail to start qos server: ", throwable);
-            try {
-                stopServer();
-            } catch (Throwable stop) {
-                logger.warn(QOS_FAILED_START_SERVER, "", "", "Fail to stop qos server: ", stop);
-            }
+
             if (qosCheck) {
-                throw new RpcException(throwable);
+                try {
+                    // Stop QoS Server to support re-start if Qos-Check is enabled
+                    stopServer();
+                } catch (Throwable stop) {
+                    logger.warn(QOS_FAILED_START_SERVER, "", "", "Fail to stop qos server: ", stop);
+                }
+                if (isServer) {
+                    // Only throws exception when export services
+                    throw new RpcException(throwable);
+                }
             }
         }
     }