From 459796336f95d56450c970b87575f22c871b4604 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 10 Jun 2011 14:34:10 +0000
Subject: [PATCH] Partial fix for OPENDJ-194: Minor improvements to change log content and configuration

---
 opends/src/server/org/opends/server/replication/protocol/StartSessionMsg.java |   40 ++++++++++++++++++++++++++--------------
 1 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/protocol/StartSessionMsg.java b/opends/src/server/org/opends/server/replication/protocol/StartSessionMsg.java
index 39aa36e..f456025 100644
--- a/opends/src/server/org/opends/server/replication/protocol/StartSessionMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/StartSessionMsg.java
@@ -98,7 +98,7 @@
     }
     else
     {
-      decode_V4(in, version);
+      decode_V45(in, version);
     }
   }
 
@@ -191,7 +191,7 @@
     }
     else
     {
-      return getBytes_V4(protocolVersion);
+      return getBytes_V45(protocolVersion);
     }
   }
 
@@ -208,11 +208,11 @@
     }
     else
     {
-      return getBytes_V4(reqProtocolVersion);
+      return getBytes_V45(reqProtocolVersion);
     }
   }
 
-  private byte[] getBytes_V4(short version)
+  private byte[] getBytes_V45(short version)
   {
     try
     {
@@ -237,12 +237,15 @@
       }
       writer.writeEndSequence();
 
-      writer.writeStartSequence();
-      for (String attrDef : eclIncludesForDeletes)
+      if (version >= ProtocolVersion.REPLICATION_PROTOCOL_V5)
       {
-        writer.writeOctetString(attrDef);
+        writer.writeStartSequence();
+        for (String attrDef : eclIncludesForDeletes)
+        {
+          writer.writeOctetString(attrDef);
+        }
+        writer.writeEndSequence();
       }
-      writer.writeEndSequence();
 
       return byteBuilder.toByteArray();
     }
@@ -302,7 +305,7 @@
   // Msg decoding
   // ============
 
-  private void decode_V4(byte[] in, short version)
+  private void decode_V45(byte[] in, short version)
   throws DataFormatException
   {
     ByteSequenceReader reader = ByteString.wrap(in).asReader();
@@ -341,16 +344,25 @@
       }
       asn1Reader.readEndSequence();
 
-      asn1Reader.readStartSequence();
-      while (asn1Reader.hasNextElement())
+      if (version >= ProtocolVersion.REPLICATION_PROTOCOL_V5)
       {
-        String s = asn1Reader.readOctetStringAsString();
-        this.eclIncludesForDeletes.add(s);
+        asn1Reader.readStartSequence();
+        while (asn1Reader.hasNextElement())
+        {
+          String s = asn1Reader.readOctetStringAsString();
+          this.eclIncludesForDeletes.add(s);
+        }
+        asn1Reader.readEndSequence();
       }
-      asn1Reader.readEndSequence();
+      else
+      {
+        // Default to using the same set of attributes for deletes.
+        this.eclIncludesForDeletes.addAll(eclIncludes);
+      }
     }
     catch (Exception e)
     {
+      throw new RuntimeException(e);
     }
   }
 

--
Gitblit v1.10.0