mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
06.12.2025 d7e652c1013c88be63967d2c849bd066f38cdd0c
Fix unavailable monitoring attributes over JMX (#558)

Co-authored-by: Jan Fyrbach <jan.fyrbach@orchitech.cz>
2 files modified
27 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java 6 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/service/ReplicationBroker.java 21 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -14,6 +14,7 @@
 * Copyright 2006-2010 Sun Microsystems, Inc.
 * Portions Copyright 2010-2016 ForgeRock AS.
 * Portions Copyright 2022-2025 3A Systems, LLC.
 * Portions Copyright 2025 Wren Security.
 */
package org.opends.server.core;
@@ -2725,6 +2726,11 @@
        if (mBean != null)
        {
          mBean.removeMonitorProvider(provider);
          if (mBean.getMonitorProviders().isEmpty() && mBean.getAlertGenerators().isEmpty())
          {
            directoryServer.mBeans.remove(monitorDN);
            directoryServer.mBeanServer.unregisterMBean(mBean.getObjectName());
          }
        }
      }
      catch (Exception e)
opendj-server-legacy/src/main/java/org/opends/server/replication/service/ReplicationBroker.java
@@ -13,6 +13,7 @@
 *
 * Copyright 2006-2010 Sun Microsystems, Inc.
 * Portions Copyright 2011-2016 ForgeRock AS.
 * Portions Copyright 2025 Wren Security.
 */
package org.opends.server.replication.service;
@@ -3251,14 +3252,30 @@
    return monitor.getMonitorInstanceName();
  }
  /**
   * Updates the currently connected replication server reference.
   * <p>
   * If the new replication server differs from the previous one, this method will:
   * <ul>
   * <li>deregister the replication monitor associated with the old server,
   * <li>close the old replication session,
   * <li>and register a replication monitor for the new server.
   *
   * @param newRS The new {@link ConnectedRS} instance to set as the currently connected replication server.
   * @return The newly set {@link ConnectedRS} instance.
   */
  private ConnectedRS setConnectedRS(final ConnectedRS newRS)
  {
    final ConnectedRS oldRS = connectedRS.getAndSet(newRS);
    if (!oldRS.equals(newRS) && oldRS.isConnected())
    ConnectedRS oldRS = connectedRS.get();
    if (!oldRS.equals(newRS))
    {
      // monitor name is changing, deregister before registering again
      deregisterReplicationMonitor();
      if (oldRS.isConnected())
      {
      oldRS.session.close();
      }
      connectedRS.set(newRS);
      registerReplicationMonitor();
    }
    return newRS;