Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-6091

Server is not properly stopped with MultipleEndpointObserver

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5, 3.0.1
    • 3.0.3, 2.7.14
    • Core
    • None
    • Unknown

    Description

      org.apache.cxf.endpoint.ServerImpl#stop() contains this code to handle MultipleEndpointObserver:

              ...
      
              if (slcMgr != null) {
                  slcMgr.stopServer(this);
              }
      
              MessageObserver mo = getDestination().getMessageObserver();
              if (mo instanceof MultipleEndpointObserver) {
                  ((MultipleEndpointObserver)mo).getEndpoints().remove(endpoint);
                  if (!((MultipleEndpointObserver)mo).getEndpoints().isEmpty()) {
                      return;
                  }
              }
      
              getDestination().setMessageObserver(null);
              stopped = true;
          }
      

      The intention seems to be to not remove the message observer until there are endpoints attached, but a side effect is that in such a case the server instance is not marked as stopped, and therefore cannot be restarted.

      One way to solve it would be to change the code above to

              if (slcMgr != null) {
                  slcMgr.stopServer(this);
              }
      
              MessageObserver mo = getDestination().getMessageObserver();
              if (mo instanceof MultipleEndpointObserver) {
                  ((MultipleEndpointObserver)mo).getEndpoints().remove(endpoint);
                  if (((MultipleEndpointObserver)mo).getEndpoints().isEmpty()) {
                      getDestination().setMessageObserver(null);
                  }
              } else {
                  getDestination().setMessageObserver(null);
              }
              stopped = true;
          }
      

      making sure that stopped is set on all (non-throwing) codepaths.

      Attachments

        1. stopstart-1.patch
          2 kB
          Vadim Beilin

        Activity

          People

            dkulp Daniel Kulp
            vadimb Vadim Beilin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: