mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
yesterday 7883fb9a24502f758f0471170135bf4a3a8b6324
Fix java/implicit-cast-in-compound-assignment CodeQL alerts (#759)
2 files modified
22 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/DatabaseMonitoringTableModel.java 11 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryIDSet.java 11 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/DatabaseMonitoringTableModel.java
@@ -13,6 +13,7 @@
 *
 * Copyright 2009 Sun Microsystems, Inc.
 * Portions Copyright 2014-2016 ForgeRock AS.
 * Portions Copyrighted 2026 3A Systems, LLC.
 */
package org.opends.guitools.controlpanel.datamodel;
@@ -231,7 +232,9 @@
    {
      boolean valueSet = false;
      boolean notImplemented = false;
      long totalValue = 0;
      // Accumulate in a double so that decimal column values are not silently
      // truncated when added to the running total.
      double totalValue = 0;
      for (String[] l : dataArray)
      {
        String value = l[i];
@@ -261,7 +264,11 @@
      }
      else if (valueSet)
      {
        line[i] = String.valueOf(totalValue);
        // Render whole totals as integers (as before) and keep the fractional
        // part only when the summed column actually carried decimal values.
        line[i] = totalValue == Math.rint(totalValue) && !Double.isInfinite(totalValue)
            ? String.valueOf((long) totalValue)
            : String.valueOf(totalValue);
      }
      else
      {
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)