From 504a43fc479d884085df9895900608dc5b0aca6f Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Fri, 31 Jul 2026 07:52:35 +0000
Subject: [PATCH] Fix CodeQL warning-severity alerts: dead checks, boxed locals and three null dereferences (#793)
---
opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
index 86a47b9..ac59a12 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
@@ -79,7 +79,6 @@
import org.opends.server.types.InitializationException;
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.BuildVersion;
-import org.opends.server.util.StaticUtils;
import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
import com.forgerock.opendj.cli.ArgumentException;
@@ -355,9 +354,10 @@
writeStatus(controlInfo.getServerDescriptor());
int period = argParser.getRefreshPeriod();
boolean first = true;
- while (period > 0)
+ // A positive refresh period means refreshing until the command is interrupted.
+ while (period > 0 && !Thread.currentThread().isInterrupted())
{
- long timeToSleep = period * 1000;
+ long timeToSleep = period * 1000L;
if (!first)
{
long t1 = System.currentTimeMillis();
@@ -369,7 +369,17 @@
if (timeToSleep > 0)
{
- StaticUtils.sleep(timeToSleep);
+ try
+ {
+ // Not StaticUtils.sleep(): it discards the interruption, which would leave this loop
+ // running with no way for the caller to stop it.
+ Thread.sleep(timeToSleep);
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ break;
+ }
}
println();
println(LocalizableMessage.raw(" ---------------------"));
@@ -1125,7 +1135,7 @@
// Interact with the user though the console to get
// LDAP connection information
final String hostName = getHostNameForLdapUrl(ci.getHostName());
- final Integer portNumber = ci.getPortNumber();
+ final int portNumber = ci.getPortNumber();
final DN bindDN = ci.getBindDN();
final String bindPassword = ci.getBindPassword();
TrustManager trustManager = ci.getTrustManager();
--
Gitblit v1.10.0