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-server-legacy/src/main/java/org/opends/quicksetup/BuildInformation.java |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/BuildInformation.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/BuildInformation.java
index 55419fd..e1d31b3 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/BuildInformation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/BuildInformation.java
@@ -275,7 +275,7 @@
    * @return String representing the major version
    */
   public Integer getMajorVersion() {
-    return Integer.valueOf(values.get(MAJOR_VERSION));
+    return getVersionNumber(MAJOR_VERSION);
   }
 
   /**
@@ -284,7 +284,7 @@
    * @return String representing the minor version
    */
   public Integer getMinorVersion() {
-    return Integer.valueOf(values.get(MINOR_VERSION));
+    return getVersionNumber(MINOR_VERSION);
   }
 
   /**
@@ -293,7 +293,24 @@
    * @return String representing the point version
    */
   public Integer getPointVersion() {
-    return Integer.valueOf(values.get(POINT_VERSION));
+    return getVersionNumber(POINT_VERSION);
+  }
+
+  /**
+   * Returns the number held by the provided version property, or zero if the
+   * build information does not hold a number for it.
+   *
+   * @param versionProperty the name of the version property
+   * @return the number held by the property
+   */
+  private Integer getVersionNumber(String versionProperty) {
+    try {
+      return Integer.valueOf(values.get(versionProperty));
+    } catch (NumberFormatException e) {
+      // The build information does not hold a version number: treat it as unknown
+      // rather than failing the version comparison with a runtime exception.
+      return 0;
+    }
   }
 
   /**

--
Gitblit v1.10.0