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/guitools/controlpanel/browser/NodeSearcherQueue.java | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/NodeSearcherQueue.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/NodeSearcherQueue.java
index 5c4deaf..31d8793 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/NodeSearcherQueue.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/NodeSearcherQueue.java
@@ -39,6 +39,7 @@
private final List<AbstractNodeTask> waitingQueue = new ArrayList<>();
private final Map<BasicNode, AbstractNodeTask> workingList = new HashMap<>();
private final ThreadGroup threadGroup;
+ private final List<Thread> threads = new ArrayList<>();
/**
@@ -53,8 +54,23 @@
for (int i = 0; i < threadCount; i++) {
Thread t = new Thread(threadGroup, this, name + "[" + i + "]");
t.setPriority(Thread.MIN_PRIORITY);
+ threads.add(t);
+ }
+ }
+
+ /**
+ * Starts the threads consuming this queue.
+ * <p>
+ * The threads are not started by the constructor so that {@code this} is not published to them
+ * before construction has completed.
+ *
+ * @return this queue
+ */
+ public NodeSearcherQueue start() {
+ for (Thread t : threads) {
t.start();
}
+ return this;
}
/**
@@ -83,7 +99,7 @@
throw new IllegalArgumentException("null argument");
}
waitingQueue.add(nodeTask);
- notify();
+ notifyAll();
// System.out.println("Queued " + nodeTask + " in " + _name);
}
@@ -113,7 +129,7 @@
if (task != null) {
task.cancel();
}
- notify();
+ notifyAll();
}
/**
@@ -197,7 +213,7 @@
throw new IllegalArgumentException("null argument");
}
workingList.remove(task.getNode());
- notify();
+ notifyAll();
// System.out.println("Flushed " + task + " from " + _name);
}
--
Gitblit v1.10.0