From 44b37afa94f2aa6dc575835ac508ed214f6b983a Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Fri, 31 Jul 2026 17:03:13 +0000
Subject: [PATCH] Fix CodeQL warning-severity alerts: process stream ownership and two leaks (#799)

---
 opendj-server-legacy/src/main/java/org/opends/quicksetup/util/OutputReader.java |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/OutputReader.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/OutputReader.java
index 5e0c2e7..d27c2b5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/OutputReader.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/OutputReader.java
@@ -19,6 +19,8 @@
 package org.opends.quicksetup.util;
 
 import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
@@ -39,16 +41,17 @@
   /**
    * The protected constructor.
    * <p>
-   * The reader is consumed until end of stream and then closed by this reader's thread, which is
-   * only launched by {@link #start()}.
+   * The stream is consumed until end of stream and then closed by this reader's thread, which is
+   * only launched by {@link #start()}. Wrapping the stream is done by that thread as well, so that
+   * this reader is the sole owner of every resource built on top of the stream.
    *
-   * @param reader  the BufferedReader of the stop process.
+   * @param stream  the output stream of the process to read.
    */
-  public OutputReader(final BufferedReader reader) {
+  public OutputReader(final InputStream stream) {
     thread = new Thread(new Runnable() {
       @Override
       public void run() {
-        try (BufferedReader in = reader) {
+        try (BufferedReader in = new BufferedReader(new InputStreamReader(stream))) {
           String line;
           while (null != (line = in.readLine())) {
             processLine(line);

--
Gitblit v1.10.0