- private synchronized Set<ObjectName> getSameNames(Set<ObjectName> superSet) {
- Set<ObjectName> result = new HashSet<>(superSet);
+ private synchronized void internalClose() {
+ // close all children
+ for (InternalJMXRegistrator child : children) {
+ // This bypasses the call to removeChild(), preventing a potential deadlock when children are being closed
+ // concurrently
+ child.internalClose();
+ }
+ children.clear();
+
+ // close registered ONs
+ for (ObjectName on : registeredObjectNames) {
+ try {
+ getMBeanServer().unregisterMBean(on);
+ } catch (Exception e) {
+ LOG.warn("Ignoring error while unregistering {}", on, e);
+ }
+ }
+ registeredObjectNames.clear();
+ }
+
+ private synchronized Set<ObjectName> getSameNames(final Set<ObjectName> superSet) {
+ final Set<ObjectName> result = new HashSet<>(superSet);