From e6213080a8f2332df41d85c42e855a881b27a007 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 03 Dec 2013 10:58:27 +0000
Subject: [PATCH] OPENDJ-1217 Servers not synchronized after a conflicting replace on multi-valued attribute on 2 different servers

---
 opends/src/server/org/opends/server/replication/server/MessageHandler.java             |    8 ++++++--
 opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java |   12 +++++-------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/MessageHandler.java b/opends/src/server/org/opends/server/replication/server/MessageHandler.java
index d94821e..beaa3b0 100644
--- a/opends/src/server/org/opends/server/replication/server/MessageHandler.java
+++ b/opends/src/server/org/opends/server/replication/server/MessageHandler.java
@@ -459,9 +459,13 @@
     {
       cursor = replicationServerDomain.getCursorFrom(serverState);
       cursor.next();
-      return cursor.getRecord().getCSN();
+      if (cursor.getRecord() != null)
+      {
+        return cursor.getRecord().getCSN();
+      }
+      return null;
     }
-    catch (Exception e)
+    catch (ChangelogException e)
     {
       return null;
     }
diff --git a/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java b/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java
index 2a9da68..79f3513 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java
+++ b/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java
@@ -595,8 +595,11 @@
           // We could not move the cursor to the expected startCSN
           if (localCursor.getSearchKeyRange(key, data, DEFAULT) != SUCCESS)
           {
-            // We could not even move the cursor close to it => failure
-            throw new ChangelogException(Message.raw("CSN not available"));
+            // We could not even move the cursor close to it
+            // => return empty cursor
+            isClosed = true;
+            cursor = null;
+            return;
           }
 
           // We can move close to the startCSN.
@@ -612,11 +615,6 @@
         cursor = localCursor;
         cursorHeld = cursor != null;
       }
-      catch (ChangelogException e)
-      {
-        StaticUtils.close(localCursor);
-        throw e;
-      }
       catch (DatabaseException e)
       {
         StaticUtils.close(localCursor);

--
Gitblit v1.10.0