From a2c7a1aafbd30c89e1c857ec8574080dcd83aa52 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Fri, 31 Jul 2026 17:01:00 +0000
Subject: [PATCH] [#794] Wait for the listen port to be open before returning from connection handler start (#796)
---
opendj-server-legacy/src/main/java/org/opends/server/api/ConnectionHandler.java | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/ConnectionHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/api/ConnectionHandler.java
index 6a33bb3..3645b8b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/ConnectionHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/ConnectionHandler.java
@@ -13,6 +13,7 @@
*
* Copyright 2006-2009 Sun Microsystems, Inc.
* Portions Copyright 2012-2016 ForgeRock AS.
+ * Portions Copyright 2026 3A Systems, LLC.
*/
package org.opends.server.api;
@@ -23,6 +24,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.server.config.server.ConnectionHandlerCfg;
@@ -53,6 +55,20 @@
private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
+ /**
+ * Maximum time a {@code start()} implementation waits for its handler thread
+ * to attempt to open the listen socket. The wait is bounded so that a handler
+ * thread dying before it reaches the listen code cannot hang the whole server
+ * startup.
+ * <p>
+ * {@code DirectoryServer.startConnectionHandlers()} starts the handlers one
+ * after another, so the worst case for a start is this value multiplied by
+ * the number of configured handlers. It is therefore kept far below the
+ * {@code start-ds} timeout ({@code DirectoryServer.DEFAULT_TIMEOUT}, 200
+ * seconds), which is generous for a {@code bind()}.
+ */
+ protected static final long LISTEN_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(15);
+
/** The monitor associated with this connection handler. */
private ConnectionHandlerMonitor monitor;
--
Gitblit v1.10.0