From 504a43fc479d884085df9895900608dc5b0aca6f Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Fri, 31 Jul 2026 07:52:35 +0000
Subject: [PATCH] Fix CodeQL warning-severity alerts: dead checks, boxed locals and three null dereferences (#793)
---
opendj-server-legacy/src/main/java/org/opends/server/util/CronExecutorService.java | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/CronExecutorService.java b/opendj-server-legacy/src/main/java/org/opends/server/util/CronExecutorService.java
index 6b74dc8..22486ec 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/CronExecutorService.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/CronExecutorService.java
@@ -12,6 +12,7 @@
* information: "Portions Copyright [year] [name of copyright owner]".
*
* Copyright 2016 ForgeRock AS.
+ * Portions Copyright 2026 3A Systems, LLC.
*/
package org.opends.server.util;
@@ -90,8 +91,11 @@
@Override
public boolean cancel(boolean mayInterruptIfRunning)
{
- return schedulerFuture.cancel(mayInterruptIfRunning)
- | (executorFuture != null && executorFuture.cancel(mayInterruptIfRunning));
+ // Both futures must be cancelled, so neither call may be short circuited.
+ final boolean schedulerCancelled = schedulerFuture.cancel(mayInterruptIfRunning);
+ final boolean executorCancelled =
+ executorFuture != null && executorFuture.cancel(mayInterruptIfRunning);
+ return schedulerCancelled || executorCancelled;
}
@Override
@@ -351,7 +355,10 @@
@Override
public boolean awaitTermination(final long timeout, final TimeUnit unit) throws InterruptedException
{
- return cronScheduler.awaitTermination(timeout, unit) & cronExecutorService.awaitTermination(timeout, unit);
+ // Both services must be awaited, so neither call may be short circuited.
+ final boolean schedulerTerminated = cronScheduler.awaitTermination(timeout, unit);
+ final boolean executorTerminated = cronExecutorService.awaitTermination(timeout, unit);
+ return schedulerTerminated && executorTerminated;
}
@Override
--
Gitblit v1.10.0