From 8e398549fb76484e922d6ebfb8519d8dd3c1c2ac Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Fri, 10 Apr 2015 10:30:37 +0000
Subject: [PATCH] OPENDJ-1932 Code cleanup

---
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java |   34 +++++++++++++++++++++-------------
 1 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
index 3728876..982adbf 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
@@ -1761,28 +1761,36 @@
   /**
    * Checks that the provided string value is a valid integer and if it is not
    * updates a list of error messages with an error.
-   * @param errors the list of error messages to be updated.
-   * @param stringValue the string value to analyze.
-   * @param minValue the minimum integer value accepted.
-   * @param maxValue the maximum integer value accepted.
-   * @param errMsg the error message to use to update the error list if the
-   * provided value is not valid.
+   *
+   * @param errors
+   *          the list of error messages to be updated.
+   * @param stringValue
+   *          the string value to analyze.
+   * @param minValue
+   *          the minimum integer value accepted.
+   * @param maxValue
+   *          the maximum integer value accepted.
+   * @param errMsg
+   *          the error message to use to update the error list if the provided
+   *          value is not valid.
+   * @return {@code true} if the provided string value is a valid integer and if
+   *         it is not updates a list of error messages with an error.
    */
-  protected void checkIntValue(Collection<LocalizableMessage> errors, String stringValue,
+  protected boolean checkIntValue(Collection<LocalizableMessage> errors, String stringValue,
       int minValue, int maxValue, LocalizableMessage errMsg)
   {
     try
     {
       int n = Integer.parseInt(stringValue);
-      if (n > maxValue || n < minValue)
+      if (minValue <= n && n <= maxValue)
       {
-        throw new RuntimeException("Invalid value");
+        return true;
       }
     }
-    catch (Throwable t)
-    {
-      errors.add(errMsg);
-    }
+    catch (NumberFormatException ignored) {}
+
+    errors.add(errMsg);
+    return false;
   }
 
   /**

--
Gitblit v1.10.0