From 65cf071e6e7a15eb81c7d8f9fa2984c9de74b10e Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Fri, 25 Jun 2010 09:47:13 +0000
Subject: [PATCH] This fix resolves an issue with replication between Windows and Unix systems. The GenerationID was different on the systems for the same input due to differences in line separators and an inappropriate exception handling.

---
 opends/src/server/org/opends/server/replication/plugin/ReplLDIFOutputStream.java |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/plugin/ReplLDIFOutputStream.java b/opends/src/server/org/opends/server/replication/plugin/ReplLDIFOutputStream.java
index 402e014..79ea095 100644
--- a/opends/src/server/org/opends/server/replication/plugin/ReplLDIFOutputStream.java
+++ b/opends/src/server/org/opends/server/replication/plugin/ReplLDIFOutputStream.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2006-2008 Sun Microsystems, Inc.
+ *      Copyright 2006-2010 Sun Microsystems, Inc.
  */
 package org.opends.server.replication.plugin;
 
@@ -30,19 +30,15 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.opends.server.replication.service.ReplicationDomain;
 import org.opends.server.util.ServerConstants;
 
 /**
  * This class creates an output stream that can be used to export entries
- * to a synchonization domain.
+ * to a synchronization domain.
  */
 public class ReplLDIFOutputStream
        extends OutputStream
 {
-  // The synchronization domain on which the export is done
-  ReplicationDomain domain;
-
   // The number of entries to be exported
   long numEntries;
 
@@ -50,16 +46,17 @@
   private long numExportedEntries;
   String entryBuffer = "";
 
+  // The checksum for computing the generation id
+  private GenerationIdChecksum checkSum = new GenerationIdChecksum();
+
   /**
    * Creates a new ReplLDIFOutputStream related to a replication
    * domain.
    *
-   * @param domain The replication domain
    * @param numEntries The max number of entry to process.
    */
-  public ReplLDIFOutputStream(ReplicationDomain domain, long numEntries)
+  public ReplLDIFOutputStream(long numEntries)
   {
-    this.domain = domain;
     this.numEntries = numEntries;
   }
 
@@ -72,6 +69,15 @@
   }
 
   /**
+   * Get the value of the underlying checksum.
+   * @return The value of the underlying checksum
+   */
+  public long getChecksumValue()
+  {
+    return checkSum.getValue();
+  }
+
+  /**
    * {@inheritDoc}
    */
   public void write(byte b[], int off, int len) throws IOException
@@ -105,6 +111,10 @@
           throw(new IOException());
         }
 
+        // Add the entry bytes to the checksum
+        byte[] entryBytes = entryBuffer.getBytes();
+        checkSum.update(entryBytes, 0, entryBytes.length);
+
         numExportedEntries++;
         entryBuffer = "";
 

--
Gitblit v1.10.0