From d0ce1d7f63e37dc3dc2233b52ced614a2cb5d71b Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Wed, 30 Sep 2026 10:57:11 +0000
Subject: [PATCH] [#1116] Default the java-class of a new LDAP connection handler to LDAPConnectionHandler2 (#1124)

---
 opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPConnectionHandler.java                          |   35 +++++++++++++++++++++++++++++++++++
 opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/LDAPConnectionHandlerConfiguration.xml |    4 ++--
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/LDAPConnectionHandlerConfiguration.xml b/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/LDAPConnectionHandlerConfiguration.xml
index f84d0c9..a21dbba 100644
--- a/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/LDAPConnectionHandlerConfiguration.xml
+++ b/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/LDAPConnectionHandlerConfiguration.xml
@@ -14,7 +14,7 @@
 
   Copyright 2007-2009 Sun Microsystems, Inc.
   Portions copyright 2011-2016 ForgeRock AS.
-  Portions copyright 2025 3A Systems, LLC
+  Portions copyright 2025-2026 3A Systems, LLC
   ! -->
 <adm:managed-object name="ldap-connection-handler"
   plural-name="ldap-connection-handlers"
@@ -80,7 +80,7 @@
     <adm:default-behavior>
       <adm:defined>
         <adm:value>
-          org.opends.server.protocols.ldap.LDAPConnectionHandler
+          org.forgerock.opendj.reactive.LDAPConnectionHandler2
         </adm:value>
       </adm:defined>
     </adm:default-behavior>
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPConnectionHandler.java b/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPConnectionHandler.java
index 5d16745..9aa744a 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPConnectionHandler.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPConnectionHandler.java
@@ -29,6 +29,7 @@
 import org.opends.server.TestCaseUtils;
 import org.forgerock.opendj.server.config.server.LDAPConnectionHandlerCfg;
 import org.opends.server.api.ClientConnection;
+import org.opends.server.api.ConnectionHandler;
 import org.forgerock.opendj.config.server.ConfigException;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.types.Attribute;
@@ -366,4 +367,38 @@
     LDAPConnHandler.applyConfigurationChange(config);
     LDAPConnHandler.finalizeConnectionHandler(reasonMsg);
   }
+
+  /**
+   * A handler created with {@code dsconfig create-connection-handler --type ldap} and no explicit
+   * {@code java-class} must run on the same class as the shipped LDAP listeners, not on the legacy
+   * {@link LDAPConnectionHandler} (issue #1116).
+   */
+  @Test
+  public void testCreatedHandlerDefaultsToLDAPConnectionHandler2() throws Exception {
+    final String handlerName = "Default Class LDAP Connection Handler";
+    final DN handlerDN = DN.valueOf("cn=" + handlerName + ",cn=Connection Handlers,cn=config");
+    TestCaseUtils.dsconfig(
+        "create-connection-handler",
+        "--type", "ldap",
+        "--handler-name", handlerName,
+        "--set", "enabled:true",
+        "--set", "listen-address:127.0.0.1",
+        "--set", "listen-port:" + TestCaseUtils.findFreePort());
+    try {
+      Entry handlerEntry = DirectoryServer.getEntry(handlerDN);
+      assertEquals(handlerEntry.parseAttribute("ds-cfg-java-class").asString(),
+          LDAPConnectionHandler2.class.getName());
+
+      ConnectionHandler<?> running = null;
+      for (ConnectionHandler<?> handler : DirectoryServer.getConnectionHandlers()) {
+        if (handlerDN.equals(handler.getComponentEntryDN())) {
+          running = handler;
+        }
+      }
+      assertNotNull(running, "the created handler is not registered");
+      assertEquals(running.getClass(), LDAPConnectionHandler2.class);
+    } finally {
+      TestCaseUtils.dsconfig("delete-connection-handler", "--handler-name", handlerName);
+    }
+  }
 }

--
Gitblit v1.10.0