From 0885d16ac22a0ecd2267bf3c8818a3a8a5a9dadb Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Fri, 31 Jul 2026 07:48:54 +0000
Subject: [PATCH] Fix CodeQL warning-severity alerts: missed wakeups, resource leaks, escaping threads (#790)

---
 opendj-server-legacy/src/main/java/org/opends/server/protocols/http/HTTPConnectionHandler.java |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/HTTPConnectionHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/HTTPConnectionHandler.java
index e5219b0..af5b881 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/HTTPConnectionHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/HTTPConnectionHandler.java
@@ -12,6 +12,7 @@
  * information: "Portions Copyright [year] [name of copyright owner]".
  *
  * Copyright 2013-2016 ForgeRock AS.
+ * Portions Copyright 2026 3A Systems, LLC.
  */
 package org.opends.server.protocols.http;
 
@@ -165,6 +166,12 @@
    */
   private final Object waitListen = new Object();
 
+  /**
+   * The condition guarding {@link #waitListen}: set once the run method has tried to open the
+   * socket port, whether it succeeded or not. Guarded by {@link #waitListen}.
+   */
+  private boolean listenAttempted;
+
   /** The friendly name of this connection handler. */
   private String friendlyName;
 
@@ -579,11 +586,15 @@
 
       try
       {
-        waitListen.wait();
+        while (!listenAttempted)
+        {
+          waitListen.wait();
+        }
       }
       catch (InterruptedException e)
       {
         // If something interrupted the start its probably better to return ASAP
+        Thread.currentThread().interrupt();
       }
     }
   }
@@ -625,7 +636,8 @@
           synchronized (waitListen)
           {
             starting = false;
-            waitListen.notify();
+            listenAttempted = true;
+            waitListen.notifyAll();
           }
         }
 
@@ -646,7 +658,8 @@
         // to start but the start process should be notified and resume its work in any cases.
         synchronized (waitListen)
         {
-          waitListen.notify();
+          listenAttempted = true;
+          waitListen.notifyAll();
         }
 
         // If we have gotten here, then we are about to start listening

--
Gitblit v1.10.0