presto-plugin-toolkit/src/main/java/io/prestosql/plugin/base/jmx/RebindSafeMBeanServer.java/RebindSafeMBeanServer/registerMBean
class RebindSafeMBeanServer:    @Override
    public ObjectInstance registerMBean(Object object, ObjectName name)
            throws MBeanRegistrationException, NotCompliantMBeanException
    {
        while (true) {
            try {
                // try to register the mbean
                return mbeanServer.registerMBean(object, name);
            }
            catch (InstanceAlreadyExistsException ignored) {
            }

            try {
                // a mbean is already installed, try to return the already registered instance
                ObjectInstance objectInstance = mbeanServer.getObjectInstance(name);
                log.debug("%s already bound to %s", name, objectInstance);
                return objectInstance;
            }
            catch (InstanceNotFoundException ignored) {
                // the mbean was removed before we could get the reference
                // start the whole process over again
            }
        }
    }