From a1634fb28238e09691ec0c90602cbce857037214 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Fri, 23 Dec 2011 10:41:51 +0000
Subject: [PATCH] Fix minor issues, optimizations detected by FindBugs.

---
 opends/src/server/org/opends/server/replication/service/ReplicationDomain.java |   39 +++++++++++++++------------------------
 1 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java b/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
index e2be1e3..38fc552 100644
--- a/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
+++ b/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
@@ -1264,8 +1264,8 @@
     @Override
     public String toString()
     {
-      return new String("[ Entry count=" + this.entryCount +
-                        ", Entry left count=" + this.entryLeftCount + "]");
+      return "[ Entry count=" + this.entryCount +
+             ", Entry left count=" + this.entryLeftCount + "]";
     }
 
     /**
@@ -1422,11 +1422,9 @@
   throws DirectoryException
   {
     DirectoryException exportRootException = null;
-    boolean contextAcquired = false;
 
     // Acquire and initialize the export context
     acquireIEContext(false);
-    contextAcquired = true;
 
     // We manage the list of servers to initialize in order :
     // - to test at the end that all expected servers have reconnected
@@ -1598,8 +1596,8 @@
               ieContext.failureList.toString()));
     }
 
-    if (contextAcquired)
-      releaseIEContext();
+    // Don't forget to release IEcontext acquired at beginning.
+    releaseIEContext();
 
     String cause = exportRootException != null ? exportRootException
         .getLocalizedMessage() : "";
@@ -1641,7 +1639,7 @@
       TRACER.debugInfo(
       "[IE] wait for start replicasWeAreWaitingFor=" + replicasWeAreWaitingFor);
 
-    boolean done = true;
+    boolean done;
     do
     {
       done = true;
@@ -1675,10 +1673,8 @@
     while ((!done) && (waitResultAttempt<1200) // 2mn
         && (!broker.shuttingDown()));
 
-    // Add to the failure list the servers that were here at start time but
-    // that never ended with the right generationId.
-    for (Integer sid : replicasWeAreWaitingFor.toArray(new Integer[0]))
-      ieContext.failureList.add(sid);
+    ieContext.failureList.addAll(
+        Arrays.asList(replicasWeAreWaitingFor.toArray(new Integer[0])));
 
     if (debugEnabled())
       TRACER.debugInfo(
@@ -1707,7 +1703,7 @@
     for (DSInfo dsi : getReplicasList())
       replicasWeAreWaitingFor.add(dsi.getDsId());
 
-    boolean done = true;
+    boolean done;
     do
     {
       done = true;
@@ -1723,8 +1719,7 @@
           continue;
         }
 
-        DSInfo dsInfo = null;
-        dsInfo = isRemoteDSConnected(serverId);
+        DSInfo dsInfo = isRemoteDSConnected(serverId);
         if (dsInfo == null)
         {
           // this server is disconnected
@@ -1769,10 +1764,8 @@
     }
     while ((!done) && (!broker.shuttingDown())); // infinite wait
 
-    // Add to the failure list the servers that were here at start time but
-    // that never ended with the right generationId.
-    for (Integer sid : replicasWeAreWaitingFor.toArray(new Integer[0]))
-      ieContext.failureList.add(sid);
+    ieContext.failureList.addAll(
+        Arrays.asList(replicasWeAreWaitingFor.toArray(new Integer[0])));
 
     if (debugEnabled())
       TRACER.debugInfo(
@@ -2058,11 +2051,9 @@
         ieContext.setException(new DirectoryException(ResultCode.OTHER,
             ERR_INIT_HEARTBEAT_LOST_DURING_EXPORT.get(
                 Integer.toString(ieContext.getSlowestServer()))));
-        // .. and abandon the export by throwing an exception.
-        IOException ioe =
-          new IOException("IOException with nested DirectoryException");
-        ioe.initCause(ieContext.getException());
-        throw ioe;
+
+        throw new IOException("IOException with nested DirectoryException",
+            ieContext.getException());
       }
 
       int ourLastExportedCnt = ieContext.msgCnt;
@@ -2616,7 +2607,7 @@
           "Server id " + serverID + " and domain " + serviceID
           + " resetGenerationId " + generationIdNewValue);
 
-    ResetGenerationIdMsg genIdMessage = null;
+    ResetGenerationIdMsg genIdMessage;
 
     if (generationIdNewValue == null)
     {

--
Gitblit v1.10.0