public static void unregisterCacheObject ( String cacheManagerName , String name , boolean stats ) { synchronized ( mBeanServer ) { ObjectName objectName = calculateObjectName ( cacheManagerName , name , stats ) ; Set < ObjectName > registeredObjectNames = mBeanServer . queryNames ( objectName , null ) ; if ( isRegistered ( cacheManagerName , name , stats ) ) { //should just be one for ( ObjectName registeredObjectName : registeredObjectNames ) { try { mBeanServer . unregisterMBean ( registeredObjectName ) ; } catch ( InstanceNotFoundException e ) { // it can happen that the instance that we want to unregister isn't found. So lets ignore it // https://github.com/hazelcast/hazelcast/issues/11055 ignore ( e ) ; } catch ( Exception e ) { throw new CacheException ( "Error unregistering object instance " + registeredObjectName + ". Error was " + e . getMessage ( ) , e ) ; } } } } }
UnRegisters the mxbean if registered already .