From 90058723ac5ab9860d1287e6051896a16aea7fa5 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 18 Jul 2014 15:44:35 +0000
Subject: [PATCH] Fixed CompositeDBCursorTest.recycleTwoElementsCursor() test.

---
 opends/src/server/org/opends/server/replication/server/changelog/je/CompositeDBCursor.java |   25 ++++++++++---------------
 1 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/changelog/je/CompositeDBCursor.java b/opends/src/server/org/opends/server/replication/server/changelog/je/CompositeDBCursor.java
index 7f271c1..c25cc44 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/je/CompositeDBCursor.java
+++ b/opends/src/server/org/opends/server/replication/server/changelog/je/CompositeDBCursor.java
@@ -93,24 +93,19 @@
       return false;
     }
 
-    if (state == UNINITIALIZED)
+    // If previous state was ready, then we must advance the first cursor
+    // (which UpdateMsg has been consumed).
+    // To keep consistent the cursors' order in the SortedSet, it is necessary
+    // to remove the first cursor, then add it again after moving it forward.
+    final Entry<DBCursor<UpdateMsg>, Data> cursorToAdvance =
+        state != UNINITIALIZED ? cursors.pollFirstEntry() : null;
+    state = READY;
+    recycleExhaustedCursors();
+    if (cursorToAdvance != null)
     {
-      state = READY;
-    }
-    else
-    {
-      // Previous state was READY => we must advance the first cursor
-      // because the UpdateMsg it is pointing has already been consumed.
-      // To keep consistent the cursors' order in the SortedSet, it is necessary
-      // to remove the first cursor, then add it again after moving it forward.
-      final Entry<DBCursor<UpdateMsg>, Data> cursorToAdvance = cursors.pollFirstEntry();
-      if (cursorToAdvance != null)
-      {
-        addCursor(cursorToAdvance.getKey(), cursorToAdvance.getValue());
-      }
+      addCursor(cursorToAdvance.getKey(), cursorToAdvance.getValue());
     }
 
-    recycleExhaustedCursors();
     removeNoLongerNeededCursors();
     incorporateNewCursors();
     return !cursors.isEmpty();

--
Gitblit v1.10.0