From 1cb904ac355146603e00a25141fa5d8d24253c5d Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Tue, 03 Jan 2012 16:06:31 +0000
Subject: [PATCH] Fix minor issues and optimizations suggested by FindBugs and NetBeans : Possible integer overflow before conversion to Long.

---
 opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java |   26 +++++++++-----------------
 1 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java b/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java
index e87e5e5..8a33e50 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java
@@ -23,7 +23,7 @@
  *
  *
  *      Copyright 2006-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011 ForgeRock AS
+ *      Portions Copyright 2011-2012 ForgeRock AS
  */
 
 package org.opends.quicksetup.installer;
@@ -36,15 +36,7 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Random;
-import java.util.Set;
-import java.util.TreeSet;
+import java.util.*;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -151,10 +143,8 @@
       importPath = new File(binPath, Installation.UNIX_IMPORT_LDIF);
     }
     argList.add(Utils.getScriptPath(importPath.getAbsolutePath()));
-    for (String arg : args)
-    {
-      argList.add(arg);
-    }
+    argList.addAll(Arrays.asList(args));
+
     String[] allArgs = new String[argList.size()];
     argList.toArray(allArgs);
     LOG.log(Level.INFO, "import-ldif arg list: "+argList);
@@ -172,6 +162,7 @@
         new BufferedReader(new InputStreamReader(process.getErrorStream()));
       new OutputReader(err)
       {
+        @Override
         public void processLine(String line)
         {
           LOG.log(Level.WARNING, "import-ldif error log: "+line);
@@ -183,6 +174,7 @@
         new BufferedReader(new InputStreamReader(process.getInputStream()));
       new OutputReader(out)
       {
+        @Override
         public void processLine(String line)
         {
           LOG.log(Level.INFO, "import-ldif out log: "+line);
@@ -531,7 +523,7 @@
       /*
        * Configure the replication server.
        */
-      ReplicationServerCfgClient replicationServer = null;
+      ReplicationServerCfgClient replicationServer;
 
       if (!sync.hasReplicationServer())
       {
@@ -1046,13 +1038,13 @@
       if (maxMemory != -1)
       {
         maxMemory = maxMemory / 2;
-        while ((1024 * 1024 * maxMemory) < currentMaxMemory &&
+        while ((1024L * 1024 * maxMemory) < currentMaxMemory &&
             !Utils.supportsOption(JavaArguments.getMaxMemoryArgument(maxMemory),
                 javaHome, installPath))
         {
           maxMemory = maxMemory / 2;
         }
-        if ((1024 * 1024 * maxMemory) > currentMaxMemory)
+        if ((1024L * 1024 * maxMemory) > currentMaxMemory)
         {
           // Supports this option.
           javaArgs.setMaxMemory(maxMemory);

--
Gitblit v1.10.0