From 4c7057e45ba8a2f3bc1f0b02b3edf14886fd1956 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Tue, 04 Aug 2026 08:31:56 +0000
Subject: [PATCH] Fix CodeQL note-severity alerts: uncaught NumberFormatException in the tools, the GUI and SNMP (#829)

---
 opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
index b9dc254..d69a014 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
@@ -384,7 +384,7 @@
      */
     public static void checkJavaVersion() throws ClientException {
         final String version = System.getProperty("java.specification.version");
-        if (Float.valueOf(version) < CliConstants.MINIMUM_JAVA_VERSION) {
+        if (getJavaSpecificationVersion(version) < CliConstants.MINIMUM_JAVA_VERSION) {
             final String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
             throw new ClientException(ReturnCode.JAVA_VERSION_INCOMPATIBLE,
                     ERR_INCOMPATIBLE_JAVA_VERSION.get(CliConstants.MINIMUM_JAVA_VERSION, version, javaBin), null);
@@ -392,6 +392,22 @@
     }
 
     /**
+     * Returns the provided java specification version as a number, or zero if it does not hold one,
+     * in which case the java version is reported as incompatible rather than failing the check with
+     * a runtime exception.
+     */
+    private static float getJavaSpecificationVersion(final String version) {
+        if (version == null) {
+            return 0;
+        }
+        try {
+            return Float.parseFloat(version);
+        } catch (final NumberFormatException e) {
+            return 0;
+        }
+    }
+
+    /**
      * Returns the default host name.
      *
      * @return The default host name or empty string if the host name cannot be resolved.

--
Gitblit v1.10.0