-
-
Notifications
You must be signed in to change notification settings - Fork 110
[#794] Wait for the listen port to be open before returning from connection handler start #796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vharseko
merged 2 commits into
OpenIdentityPlatform:master
from
vharseko:issues/794-wait-for-ldap-listener
Jul 31, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
...-legacy/src/test/java/org/opends/server/protocols/http/HTTPConnectionHandlerTestCase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /* | ||
| * The contents of this file are subject to the terms of the Common Development and | ||
| * Distribution License (the License). You may not use this file except in compliance with the | ||
| * License. | ||
| * | ||
| * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the | ||
| * specific language governing permission and limitations under the License. | ||
| * | ||
| * When distributing Covered Software, include this CDDL Header Notice in each file and include | ||
| * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL | ||
| * Header, with the fields enclosed by brackets [] replaced by your own identifying | ||
| * information: "Portions copyright [year] [name of copyright owner]". | ||
| * | ||
| * Copyright 2026 3A Systems, LLC. | ||
| */ | ||
| package org.opends.server.protocols.http; | ||
|
|
||
| import static org.testng.Assert.*; | ||
|
|
||
| import org.forgerock.i18n.LocalizableMessage; | ||
| import org.forgerock.opendj.server.config.meta.HTTPConnectionHandlerCfgDefn; | ||
| import org.forgerock.opendj.server.config.server.HTTPConnectionHandlerCfg; | ||
| import org.opends.server.DirectoryServerTestCase; | ||
| import org.opends.server.TestCaseUtils; | ||
| import org.opends.server.core.DirectoryServer; | ||
| import org.opends.server.extensions.InitializationUtils; | ||
| import org.opends.server.types.Entry; | ||
| import org.testng.annotations.BeforeClass; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| @SuppressWarnings("javadoc") | ||
| @Test(groups = { "precommit", "http" }, sequential = true) | ||
| public class HTTPConnectionHandlerTestCase extends DirectoryServerTestCase | ||
| { | ||
| private static final LocalizableMessage STOP_REASON = LocalizableMessage.raw("Don't need a reason."); | ||
|
|
||
| @BeforeClass | ||
| public void setUp() throws Exception | ||
| { | ||
| // This test suite depends on having the schema available, so we'll start the server. | ||
| TestCaseUtils.startServer(); | ||
| } | ||
|
|
||
| /** | ||
| * The start method must not return before the handler thread has attempted to start the embedded | ||
| * HTTP server, otherwise a client connecting right after the handler has been enabled through | ||
| * dsconfig can be refused. | ||
| * | ||
| * @throws Exception | ||
| * if the handler cannot be instantiated or started. | ||
| */ | ||
| @Test | ||
| public void testStartWaitsForListenPort() throws Exception | ||
| { | ||
| final int listenPort = TestCaseUtils.findFreePort(); | ||
| Entry handlerEntry = TestCaseUtils.makeEntry( | ||
| "dn: cn=HTTP Connection Handler,cn=Connection Handlers,cn=config", | ||
| "objectClass: top", | ||
| "objectClass: ds-cfg-connection-handler", | ||
| "objectClass: ds-cfg-http-connection-handler", | ||
| "cn: HTTP Connection Handler", | ||
| "ds-cfg-java-class: org.opends.server.protocols.http.HTTPConnectionHandler", | ||
| "ds-cfg-enabled: true", | ||
| "ds-cfg-listen-address: 127.0.0.1", | ||
| "ds-cfg-listen-port: " + listenPort, | ||
| "ds-cfg-accept-backlog: 128", | ||
| "ds-cfg-keep-stats: false", | ||
| "ds-cfg-use-tcp-keep-alive: true", | ||
| "ds-cfg-use-tcp-no-delay: true", | ||
| "ds-cfg-allow-tcp-reuse-address: true", | ||
| "ds-cfg-max-request-size: 5 megabytes", | ||
| "ds-cfg-buffer-size: 4096 bytes", | ||
| "ds-cfg-max-blocked-write-time-limit: 2 minutes", | ||
| "ds-cfg-use-ssl: false", | ||
| "ds-cfg-ssl-client-auth-policy: optional", | ||
| "ds-cfg-ssl-cert-nickname: server-cert"); | ||
| HTTPConnectionHandlerCfg config = | ||
| InitializationUtils.getConfiguration(HTTPConnectionHandlerCfgDefn.getInstance(), handlerEntry); | ||
|
|
||
| HTTPConnectionHandler handler = new HTTPConnectionHandler(); | ||
| handler.initializeConnectionHandler(DirectoryServer.getInstance().getServerContext(), config); | ||
| try | ||
| { | ||
| handler.start(); | ||
|
|
||
| // No retry loop here on purpose: once start() has returned, the port must already be open. | ||
| TestCaseUtils.assertPortIsAcceptingConnections(listenPort); | ||
| } | ||
| finally | ||
| { | ||
| handler.processServerShutdown(STOP_REASON); | ||
| handler.finalizeConnectionHandler(STOP_REASON); | ||
| handler.join(10000); | ||
| assertFalse(handler.isAlive(), "the connection handler thread is still running"); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.