From ebb19c5816399b83c42b8f9194dbf3d9296975a3 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Thu, 30 Jul 2026 07:45:56 +0000
Subject: [PATCH] Fix concurrency and equals-contract CodeQL alerts (#785)
---
opendj-server-legacy/src/main/java/org/opends/quicksetup/Application.java | 30 ++++++++++++++++++++++--------
1 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/Application.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/Application.java
index 53bcf6a..18a3f40 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/Application.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/Application.java
@@ -13,6 +13,7 @@
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2012-2016 ForgeRock AS.
+ * Portions Copyright 2026 3A Systems, LLC.
*/
package org.opends.quicksetup;
@@ -799,9 +800,12 @@
/** Class used to add points periodically to the end of the logs. */
protected class PointAdder implements Runnable
{
- private Thread t;
- private boolean stopPointAdder;
- private boolean pointAdderStopped;
+ /** Written by start() and read by stop(), hence volatile. */
+ private volatile Thread t;
+ /** Written by stop() and read by the point adder thread, hence volatile. */
+ private volatile boolean stopPointAdder;
+ /** Written by the point adder thread and read by stop(), hence volatile. */
+ private volatile boolean pointAdderStopped;
/** Default constructor. */
public PointAdder()
@@ -825,21 +829,31 @@
t.start();
}
- /** Stops the PointAdder: points are no longer added at the end of the logs periodically. */
- public synchronized void stop()
+ /**
+ * Stops the PointAdder: points are no longer added at the end of the logs periodically.
+ * <p>
+ * Calling this method on a PointAdder that was never started is a no-op.
+ */
+ public void stop()
{
stopPointAdder = true;
+ final Thread thread = t;
+ if (thread == null)
+ {
+ return;
+ }
while (!pointAdderStopped)
{
+ thread.interrupt();
try
{
- t.interrupt();
// To allow the thread to set the boolean.
Thread.sleep(100);
}
- catch (Throwable t)
+ catch (InterruptedException e)
{
- // do nothing
+ Thread.currentThread().interrupt();
+ break;
}
}
}
--
Gitblit v1.10.0