From 715bf2629d654ce0427a7edf564bbdd390c5bc88 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Mon, 23 Dec 2013 13:54:49 +0000
Subject: [PATCH] Fix OPENDJ-1115: Internal errors from ModifyOperation - change number was not found in pending list

---
 opends/src/server/org/opends/server/replication/plugin/RemotePendingChanges.java |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/plugin/RemotePendingChanges.java b/opends/src/server/org/opends/server/replication/plugin/RemotePendingChanges.java
index e8815cc..52c79ca 100644
--- a/opends/src/server/org/opends/server/replication/plugin/RemotePendingChanges.java
+++ b/opends/src/server/org/opends/server/replication/plugin/RemotePendingChanges.java
@@ -53,7 +53,7 @@
   /**
    * A map used to store the pending changes.
    */
-  private SortedMap<CSN, PendingChange> pendingChanges =
+  private final SortedMap<CSN, PendingChange> pendingChanges =
     new TreeMap<CSN, PendingChange>();
 
   /**
@@ -61,13 +61,13 @@
    * not been replayed correctly because they are dependent on
    * another change to be completed.
    */
-  private SortedSet<PendingChange> dependentChanges =
+  private final SortedSet<PendingChange> dependentChanges =
     new TreeSet<PendingChange>();
 
   /**
    * The ServerState that will be updated when LDAPUpdateMsg are fully replayed.
    */
-  private ServerState state;
+  private final ServerState state;
 
   /**
    * Creates a new RemotePendingChanges using the provided ServerState.
@@ -96,11 +96,14 @@
    *
    * @param update The LDAPUpdateMsg that was received from the replication
    *               server and that will be added to the pending list.
+   * @return {@code false} if the update was already registered in the pending
+   *         changes.
    */
-  public synchronized void putRemoteUpdate(LDAPUpdateMsg update)
+  public synchronized boolean putRemoteUpdate(LDAPUpdateMsg update)
   {
     CSN csn = update.getCSN();
-    pendingChanges.put(csn, new PendingChange(csn, null, update));
+    return pendingChanges.put(csn,
+        new PendingChange(csn, null, update)) == null;
   }
 
   /**

--
Gitblit v1.10.0