code: public static void unregisterObject(ObjectName objectName, MBeanServer mbeanServer) {
          if (objectName == null) {
              return;
          }
          try {
              mbeanServer.unregisterMBean(objectName);
          } catch (Exception e) {
              logger.warn("Failure to unregister {}", objectName, e);
          }
      }
docs: Try to unregister given <code>objectName</code>.
  
  If given <code>objectName</code> is <code>null</code>, nothing is done.
  If registration fails, a {@link Logger#warn(String)} message is emitted and <code>null</code> is returned.
  
  @param objectName  objectName to unregister
  @param mbeanServer MBeanServer to which the objectName is unregistered