Details
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.