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/quicksetup/util/Utils.java | 52 +++++++++++++++++++++++++++-------------------------
1 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java
index 4117b84..a9692c4 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java
@@ -166,40 +166,42 @@
final Process process = pb.start();
logger.info(LocalizableMessage.raw("launching " + args + " with env: " + env));
InputStream is = process.getInputStream();
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
- String line;
boolean errorDetected = false;
- while (null != (line = reader.readLine()))
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(is)))
{
- logger.info(LocalizableMessage.raw("The output: " + line));
- if (line.contains("ERROR: The detected Java version"))
+ String line;
+ while (null != (line = reader.readLine()))
{
- if (isWindows())
+ logger.info(LocalizableMessage.raw("The output: " + line));
+ if (line.contains("ERROR: The detected Java version"))
{
- // If we are running windows, the process get blocked waiting for
- // user input. Just wait for a certain time to print the output
- // in the logger and then kill the process.
- Thread t = new Thread(new Runnable()
+ if (isWindows())
{
- @Override
- public void run()
+ // If we are running windows, the process get blocked waiting for
+ // user input. Just wait for a certain time to print the output
+ // in the logger and then kill the process.
+ Thread t = new Thread(new Runnable()
{
- try
+ @Override
+ public void run()
{
- Thread.sleep(3000);
- // To see if the process is over, call the exitValue method.
- // If it is not over, a IllegalThreadStateException.
- process.exitValue();
+ try
+ {
+ Thread.sleep(3000);
+ // To see if the process is over, call the exitValue method.
+ // If it is not over, a IllegalThreadStateException.
+ process.exitValue();
+ }
+ catch (Throwable t)
+ {
+ process.destroy();
+ }
}
- catch (Throwable t)
- {
- process.destroy();
- }
- }
- });
- t.start();
+ });
+ t.start();
+ }
+ errorDetected = true;
}
- errorDetected = true;
}
}
process.waitFor();
--
Gitblit v1.10.0