From d11926a41394b9bc2f3669078947db3ddc9d0e2c Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jn.rouvignac@gmail.com>
Date: Mon, 31 Aug 2015 08:49:43 +0000
Subject: [PATCH] Preliminary OPENDJ-1192 (PR #8) Modify request replay failures

---
 opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java |   48 +++++++++++++++++++++++++++---------------------
 1 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java
index 036ea9e..5c9b609 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java
@@ -241,18 +241,18 @@
            * skip this mod
            */
           modsIterator.remove();
-          break;
+          return true;
         }
 
         if (!conflictDelete(csn, m, modifiedEntry))
         {
           modsIterator.remove();
+          return true;
         }
-        break;
+        return false;
 
       case ADD:
-        conflictAdd(csn, m, modsIterator);
-        break;
+        return conflictAdd(csn, m, modsIterator);
 
       case REPLACE:
         if (csn.isOlderThan(getDeleteTime()))
@@ -261,15 +261,14 @@
            * skip this mod
            */
           modsIterator.remove();
-          break;
+          return true;
         }
 
-        /* save the values that are added by the replace operation
-         * into addedValues
-         * first process the replace as a delete operation -> this generate
-         * a list of values that should be kept
-         * then process the addedValues as if they were coming from a add
-         * -> this generate the list of values that needs to be added
+        /* save the values that are added by the replace operation into addedValues
+         * first process the replace as a delete operation
+         * -> this generates a list of values that should be kept
+         * then process the addedValues as if they were coming from an add
+         * -> this generates the list of values that needs to be added
          * concatenate the 2 generated lists into a replace
          */
         Attribute addedValues = m.getAttribute();
@@ -284,13 +283,15 @@
         AttributeBuilder builder = new AttributeBuilder(keptValues);
         builder.addAll(m.getAttribute());
         m.setAttribute(builder.toAttribute());
-        break;
+        return false;
 
       case INCREMENT:
         // TODO : FILL ME
-        break;
+        return false;
+
+      default:
+        return false;
       }
-      return true;
     }
     else
     {
@@ -485,14 +486,17 @@
   }
 
   /**
-   * Process a add attribute values that is conflicting with a previous
-   * modification.
+   * Process a add attribute values that is conflicting with a previous modification.
    *
-   * @param csn  the historical info associated to the entry
-   * @param m the modification that is being processed
-   * @param modsIterator iterator on the list of modification
+   * @param csn
+   *          the historical info associated to the entry
+   * @param m
+   *          the modification that is being processed
+   * @param modsIterator
+   *          iterator on the list of modification
+   * @return {@code true} if a conflict was detected, {@code false} otherwise.
    */
-  private void conflictAdd(CSN csn, Modification m, Iterator<Modification> modsIterator)
+  private boolean conflictAdd(CSN csn, Modification m, Iterator<Modification> modsIterator)
   {
     /*
      * if historicalattributedelete is newer forget this mod else find
@@ -510,7 +514,7 @@
        * forget this MOD ADD
        */
       modsIterator.remove();
-      return;
+      return true;
     }
 
     AttributeBuilder builder = new AttributeBuilder(m.getAttribute());
@@ -576,12 +580,14 @@
     if (attr.isEmpty())
     {
       modsIterator.remove();
+      return true;
     }
 
     if (csn.isNewerThan(getLastUpdateTime()))
     {
       lastUpdateTime = csn;
     }
+    return false;
   }
 
   @Override

--
Gitblit v1.10.0