From 99480fcbcb68be6a357f6218668feab697e1a93d Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Tue, 07 Jul 2009 14:55:26 +0000
Subject: [PATCH] Fix for 4096 MonitorMsg is not compatible with replication version

---
 opends/src/server/org/opends/server/replication/protocol/StartMsg.java |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/protocol/StartMsg.java b/opends/src/server/org/opends/server/replication/protocol/StartMsg.java
index aa352cb..2ec19b7 100644
--- a/opends/src/server/org/opends/server/replication/protocol/StartMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/StartMsg.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2006-2008 Sun Microsystems, Inc.
+ *      Copyright 2006-2009 Sun Microsystems, Inc.
  */
 package org.opends.server.replication.protocol;
 
@@ -75,17 +75,21 @@
    * Encode the header for the start message.
    *
    * @param type The type of the message to create.
-   * @param additionalLength additional length needed to encode the remaining
+   * @param additionalLength Additional length needed to encode the remaining
    *                         part of the UpdateMessage.
+   * @param protocolVersion  The version to use when encoding the header.
    * @return a byte array containing the common header and enough space to
    *         encode the remaining bytes of the UpdateMessage as was specified
    *         by the additionalLength.
    *         (byte array length = common header length + additionalLength)
    * @throws UnsupportedEncodingException if UTF-8 is not supported.
    */
-  public byte[] encodeHeader(byte type, int additionalLength)
+  public byte[] encodeHeader(
+      byte type, int additionalLength,
+      short protocolVersion)
   throws UnsupportedEncodingException
   {
+
     byte[] byteGenerationID =
       String.valueOf(generationId).getBytes("UTF-8");
 
@@ -101,7 +105,7 @@
     encodedMsg[0] = type;
 
     /* put the protocol version */
-    encodedMsg[1] = (byte)ProtocolVersion.getCurrentVersion();
+    encodedMsg[1] = (byte)protocolVersion;
 
     /* put the generationId */
     int pos = 2;
@@ -192,11 +196,11 @@
     {
       /* then read the version */
       short readVersion = (short)encodedMsg[1];
-      if (readVersion != ProtocolVersion.getCurrentVersion())
+      if (readVersion < ProtocolVersion.REPLICATION_PROTOCOL_V2)
         throw new DataFormatException("Not a valid message: type is " +
           encodedMsg[0] + " but protocol version byte is " + readVersion +
           " instead of " + ProtocolVersion.getCurrentVersion());
-      protocolVersion = ProtocolVersion.getCurrentVersion();
+      protocolVersion = readVersion;
 
       /* read the generationId */
       int pos = 2;

--
Gitblit v1.10.0