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/util/Utils.java | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java
index 2824d9c..9ccef47 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java
@@ -1838,6 +1838,35 @@
cmdLines.add(cmdReplicationServer);
return cmdLines;
}
+
+ /**
+ * Returns the number held by the provided field value, or the provided default value if it does
+ * not hold a number.
+ * <p>
+ * The panels validate their fields before using their values, so the default value is only
+ * returned when a field has not been validated beforehand.
+ *
+ * @param value
+ * the value to be parsed, which may be {@code null}
+ * @param defaultValue
+ * the value to return when {@code value} does not hold a number
+ * @return the number held by the provided value
+ */
+ public static int parseIntOrDefault(String value, int defaultValue)
+ {
+ if (value == null)
+ {
+ return defaultValue;
+ }
+ try
+ {
+ return Integer.parseInt(value.trim());
+ }
+ catch (NumberFormatException e)
+ {
+ return defaultValue;
+ }
+ }
}
/**
--
Gitblit v1.10.0