You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2021/04/30 19:29:01 UTC

[cxf] branch master updated: [CXF-8533]ensure an endpoint destination which is still in use won't be shutdown inproperly

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

ffang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new c5d7526  [CXF-8533]ensure an endpoint destination which is still in use won't be shutdown inproperly
c5d7526 is described below

commit c5d75269335fc1aab126708d1d7ff2aa86bce39d
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Fri Apr 30 15:28:38 2021 -0400

    [CXF-8533]ensure an endpoint destination which is still in use won't be shutdown inproperly
---
 .../java/org/apache/cxf/endpoint/ServerImpl.java     | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java b/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
index 051e27f..c2f0981 100644
--- a/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
+++ b/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
@@ -52,6 +52,7 @@ public class ServerImpl implements Server {
     private InstrumentationManager iMgr;
     private ManagedEndpoint mep;
     private boolean stopped = true;
+    private boolean destoryDest = true;
 
     public ServerImpl(Bus bus,
                       Endpoint endpoint,
@@ -124,8 +125,17 @@ public class ServerImpl implements Server {
             return;
         }
         LOG.fine("Server is starting.");
-
-        bindingFactory.addListener(destination, endpoint);
+        
+        try {
+            bindingFactory.addListener(destination, endpoint);
+        } catch (RuntimeException e) {
+            if (e.getMessage().contains("endpoint already registered on address")) {
+                //this destination is used by another endpoint with same endpoint address
+                //so shouldn't be destoried by this server
+                this.destoryDest = false;
+            }
+            throw e;
+        }
 
         // register the active server to run
         if (null != serverRegistry) {
@@ -183,8 +193,10 @@ public class ServerImpl implements Server {
 
     public void destroy() {
         stop();
-        // we should shutdown the destination here
-        getDestination().shutdown();
+        if (this.destoryDest) {
+            //we should shutdown the destination here
+            getDestination().shutdown();
+        }
 
         if (null != serverRegistry) {
             LOG.fine("unregister the server to serverRegistry ");