From 7629e7309096d7d5509ba683ec31590b9b8acecc Mon Sep 17 00:00:00 2001 From: Ian Luo Date: Fri, 9 Nov 2018 18:41:20 +0800 Subject: [PATCH] #2762: [Dubbo - qos-http] stopServer should be invoked ? (#2768) --- .../dubbo/qos/protocol/QosProtocolWrapper.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/protocol/QosProtocolWrapper.java b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/protocol/QosProtocolWrapper.java index 73d1f56a797..e7a8ff6bee6 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/protocol/QosProtocolWrapper.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/protocol/QosProtocolWrapper.java @@ -74,13 +74,10 @@ public Invoker refer(Class type, URL url) throws RpcException { @Override public void destroy() { protocol.destroy(); + stopServer(); } private void startQosServer(URL url) { - if (!hasStarted.compareAndSet(false, true)) { - return; - } - try { boolean qosEnable = url.getParameter(QOS_ENABLE,true); if (!qosEnable) { @@ -90,6 +87,10 @@ private void startQosServer(URL url) { return; } + if (!hasStarted.compareAndSet(false, true)) { + return; + } + int port = url.getParameter(QOS_PORT, DEFAULT_PORT); boolean acceptForeignIp = Boolean.parseBoolean(url.getParameter(ACCEPT_FOREIGN_IP,"false")); Server server = com.alibaba.dubbo.qos.server.Server.getInstance(); @@ -101,4 +102,11 @@ private void startQosServer(URL url) { logger.warn("Fail to start qos server: ", throwable); } } + + /*package*/ void stopServer() { + if (hasStarted.compareAndSet(true, false)) { + Server server = Server.getInstance(); + server.stop(); + } + } }