From 053bd871061fe5a094c1c2c6bea65811c038c622 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 06 Jun 2014 14:19:37 +0000
Subject: [PATCH] (CR-3599) Convert all protocols message to use ByteArrayBuilder + ByteArrayScanner

---
 opendj3-server-dev/src/server/org/opends/server/replication/protocol/HeartbeatMsg.java |   21 ++++++---------------
 1 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/replication/protocol/HeartbeatMsg.java b/opendj3-server-dev/src/server/org/opends/server/replication/protocol/HeartbeatMsg.java
index 2165a6d..a71d187 100644
--- a/opendj3-server-dev/src/server/org/opends/server/replication/protocol/HeartbeatMsg.java
+++ b/opendj3-server-dev/src/server/org/opends/server/replication/protocol/HeartbeatMsg.java
@@ -24,7 +24,6 @@
  *      Copyright 2008 Sun Microsystems, Inc.
  *      Portions Copyright 2013-2014 ForgeRock AS.
  */
-
 package org.opends.server.replication.protocol;
 
 import java.util.zip.DataFormatException;
@@ -52,20 +51,18 @@
    * @throws java.util.zip.DataFormatException If the byte array does not
    * contain a valid encoded form of the message.
    */
-  public HeartbeatMsg(byte[] in) throws DataFormatException
+  HeartbeatMsg(byte[] in) throws DataFormatException
   {
     /* The heartbeat message is encoded in the form :
      * <msg-type>
      */
-
-    /* first byte is the type */
     if (in.length != 1 || in[0] != MSG_TYPE_HEARTBEAT)
-      throw new DataFormatException("Input is not a valid Heartbeat LocalizableMessage.");
+    {
+      throw new DataFormatException("Input is not a valid Heartbeat Message.");
+    }
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public byte[] getBytes(short protocolVersion)
   {
@@ -73,13 +70,7 @@
      * The heartbeat message contains:
      * <msg-type>
      */
-    int length = 1;
-    byte[] resultByteArray = new byte[length];
-
-    /* put the message type */
-    resultByteArray[0] = MSG_TYPE_HEARTBEAT;
-
-    return resultByteArray;
+    return new byte[] { MSG_TYPE_HEARTBEAT };
   }
 
   /** {@inheritDoc} */

--
Gitblit v1.10.0