From df0af76ae6838013c0e66bf5d17c7e7aae44dac2 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Thu, 01 Oct 2026 09:35:55 +0000
Subject: [PATCH] [#1120] Apply a change to plugin-type on an enabled plugin without disabling and enabling it again (#1127)

---
 opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
index f42d845..34ac476 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
@@ -170,7 +170,6 @@
                                      ReferentialIntegrityPluginCfg pluginCfg)
          throws ConfigException
   {
-    pluginCfg.addReferentialIntegrityChangeListener(this);
     LinkedList<LocalizableMessage> unacceptableReasons = new LinkedList<>();
 
     if (!isConfigurationAcceptableIgnoringCheckReferencesPluginTypes(pluginCfg, unacceptableReasons))
@@ -178,6 +177,10 @@
       throw new ConfigException(unacceptableReasons.getFirst());
     }
 
+    // Only after the check: finalizePlugin() cannot remove a listener registered by a refused
+    // configuration, because the configuration it removes it from is set in applyConfigurationChange().
+    pluginCfg.addReferentialIntegrityChangeListener(this);
+
     // Enabling the plugin or changing its configuration is refused without these types, but a configuration
     // already stored without them (the entry shipped before issue #1118) is loaded with a warning: refusing
     // it would also stop the delete and modify DN clean-up, which does not need them.
@@ -928,6 +931,11 @@
 
   @Override
   public final void finalizePlugin() {
+    if (currentConfiguration == null)
+    {
+      // initializePlugin() refused the configuration before registering anything.
+      return;
+    }
     currentConfiguration.removeReferentialIntegrityChangeListener(this);
     if(interval > 0)
     {

--
Gitblit v1.10.0