From 88cfe5045d77d433ce02b0ef10ee84c9d4fb15e2 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 23 May 2014 15:17:15 +0000
Subject: [PATCH] (CR-3599) Convert all protocols message to use ByteArrayBuilder + ByteArrayScanner
---
opends/src/server/org/opends/server/replication/protocol/HeartbeatMsg.java | 21 ++++++---------------
1 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/protocol/HeartbeatMsg.java b/opends/src/server/org/opends/server/replication/protocol/HeartbeatMsg.java
index e2d7d4d..a117e90 100644
--- a/opends/src/server/org/opends/server/replication/protocol/HeartbeatMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/HeartbeatMsg.java
@@ -22,9 +22,8 @@
*
*
* Copyright 2008 Sun Microsystems, Inc.
- * Portions copyright 2013 ForgeRock AS.
+ * 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 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