francescomari opened a new pull request, #482:
URL: https://github.com/apache/felix-dev/pull/482

   ## Summary
   
   When `stopJetty()` runs during a configuration-triggered restart, Jetty's 
JMX MBeans are not unregistered before the `Server` is stopped. On the 
subsequent `startJetty()`, the new `Server` creates a new `MBeanServerTracker` 
which tries to register `org.eclipse.jetty.server:type=server,id=0` — but the 
old registration still exists, causing an `InstanceAlreadyExistsException`.
   
   ## Root cause
   
   Two issues:
   
   1. **`JettyService.stopJetty()`** closes the `MBeanServerTracker` *after* 
`server.stop()`. By the time the tracker is closed, the server's component tree 
has already been torn down, so `MBeanContainer` can no longer walk the tree to 
unregister its MBeans. They remain in the platform `MBeanServer` as stale 
entries.
   
   2. **`MBeanServerTracker.removedService()`** removes the `MBeanContainer` as 
an event listener and calls `super.removedService()`, but never calls 
`MBeanContainer.destroy()`. Without `destroy()`, the container does not 
unregister the MBeans it previously registered.
   
   ## Changes
   
   - **`JettyService.stopJetty()`** (both jetty and jetty12): move 
`mbeanServerTracker.close()` *before* `server.stop()` so the tracker is closed 
while the server's component tree is still intact and MBeans can be properly 
unregistered
   - **`MBeanServerTracker.removedService()`** (both jetty and jetty12): call 
`service.destroy()` before removing the event listener, so `MBeanContainer` 
unregisters all MBeans it owns


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to