From 7883fb9a24502f758f0471170135bf4a3a8b6324 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Fri, 24 Jul 2026 15:05:40 +0000
Subject: [PATCH] Fix java/implicit-cast-in-compound-assignment CodeQL alerts (#759)

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java
index 3066154..600855e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java
@@ -13,6 +13,7 @@
  *
  * Copyright 2006-2008 Sun Microsystems, Inc.
  * Portions Copyright 2014-2016 ForgeRock AS.
+ * Portions Copyrighted 2026 3A Systems, LLC.
  */
 package org.opends.server.backends.pluggable;
 
@@ -668,7 +669,7 @@
   {
     checkNotNull(sets, "sets must not be null");
 
-    int count = 0;
+    long count = 0;
 
     boolean containsUndefinedSet = false;
     for (EntryIDSet l : sets)
@@ -684,13 +685,15 @@
       count += l.size();
     }
 
-    if (containsUndefinedSet)
+    if (containsUndefinedSet || count > Integer.MAX_VALUE)
     {
+      // Either at least one set was undefined, or the combined number of IDs
+      // cannot be represented by a single array: fall back to an undefined set.
       return newUndefinedSet();
     }
 
     boolean needSort = false;
-    long[] n = new long[count];
+    long[] n = new long[(int) count];
     int pos = 0;
     for (EntryIDSet l : sets)
     {
@@ -698,7 +701,7 @@
       {
         needSort |= pos > 0 && l.iterator().next().longValue() < n[pos - 1];
         System.arraycopy(l.getIDs(), 0, n, pos, l.getIDs().length);
-        pos += l.size();
+        pos += (int) l.size();
       }
     }
     if (needSort)

--
Gitblit v1.10.0