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/server/backends/pluggable/ID2Entry.java |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java
index a4e6c70..73cb4d4 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java
@@ -13,6 +13,7 @@
  *
  * Copyright 2006-2010 Sun Microsystems, Inc.
  * Portions Copyright 2012-2016 ForgeRock AS.
+ * Portions Copyright 2026 3A Systems, LLC.
  */
 package org.opends.server.backends.pluggable;
 
@@ -268,21 +269,24 @@
         {
           is = new InflaterInputStream(is);
         }
-        byte[] data = new byte[encodedEntryLen];
-        int readBytes;
-        int position = 0;
-        int leftToRead = encodedEntryLen;
-        // CipherInputStream does not read more than block size...
-        do
+        try (InputStream entryStream = is)
         {
-          if ((readBytes = is.read(data, position, leftToRead)) == -1 )
+          byte[] data = new byte[encodedEntryLen];
+          int readBytes;
+          int position = 0;
+          int leftToRead = encodedEntryLen;
+          // CipherInputStream does not read more than block size...
+          do
           {
-            throw DecodeException.error(ERR_CANNOT_DECODE_ENTRY.get());
-          }
-          position += readBytes;
-          leftToRead -= readBytes;
-        } while (leftToRead > 0 && readBytes > 0);
-        return Entry.decode(ByteString.wrap(data).asReader(), compressedSchema);
+            if ((readBytes = entryStream.read(data, position, leftToRead)) == -1 )
+            {
+              throw DecodeException.error(ERR_CANNOT_DECODE_ENTRY.get());
+            }
+            position += readBytes;
+            leftToRead -= readBytes;
+          } while (leftToRead > 0 && readBytes > 0);
+          return Entry.decode(ByteString.wrap(data).asReader(), compressedSchema);
+        }
       }
       catch (CryptoManagerException cme)
       {

--
Gitblit v1.10.0