From 003531d1be38a2abd2b875452da1a752273576a2 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Thu, 14 Jun 2007 15:46:00 +0000
Subject: [PATCH] cleanup : suppress a few TODO comments by throwing exception and logging proper error message in case of unlikely failures.
---
opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java | 110 ++++++++++++++++++++++++++----------------------------
1 files changed, 53 insertions(+), 57 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java b/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java
index 7a3ebd3..b4f9935 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java
@@ -167,68 +167,64 @@
* Get the byte array representation of this Message.
*
* @return The byte array representation of this Message.
+ *
+ * @throws UnsupportedEncodingException When the encoding of the message
+ * failed because the UTF-8 encoding is not supported.
*/
@Override
- public byte[] getBytes()
+ public byte[] getBytes() throws UnsupportedEncodingException
{
- try
+ byte[] byteNewRdn = newRDN.getBytes("UTF-8");
+ byte[] byteNewSuperior = null;
+ byte[] byteNewSuperiorId = null;
+
+ // calculate the length necessary to encode the parameters
+ int length = byteNewRdn.length + 1 + 1;
+ if (newSuperior != null)
{
- byte[] byteNewRdn = newRDN.getBytes("UTF-8");
- byte[] byteNewSuperior = null;
- byte[] byteNewSuperiorId = null;
-
- // calculate the length necessary to encode the parameters
- int length = byteNewRdn.length + 1 + 1;
- if (newSuperior != null)
- {
- byteNewSuperior = newSuperior.getBytes("UTF-8");
- length += byteNewSuperior.length + 1;
- }
- else
- length += 1;
-
- if (newSuperiorId != null)
- {
- byteNewSuperiorId = newSuperiorId.getBytes("UTF-8");
- length += byteNewSuperiorId.length + 1;
- }
- else
- length += 1;
-
- byte[] resultByteArray = encodeHeader(MSG_TYPE_MODIFYDN_REQUEST, length);
- int pos = resultByteArray.length - length;
-
- /* put the new RDN and a terminating 0 */
- pos = addByteArray(byteNewRdn, resultByteArray, pos);
-
- /* put the newsuperior and a terminating 0 */
- if (newSuperior != null)
- {
- pos = addByteArray(byteNewSuperior, resultByteArray, pos);
- }
- else
- resultByteArray[pos++] = 0;
-
- /* put the newsuperiorId and a terminating 0 */
- if (newSuperiorId != null)
- {
- pos = addByteArray(byteNewSuperiorId, resultByteArray, pos);
- }
- else
- resultByteArray[pos++] = 0;
-
- /* put the deleteoldrdn flag */
- if (deleteOldRdn)
- resultByteArray[pos++] = 1;
- else
- resultByteArray[pos++] = 0;
-
- return resultByteArray;
- } catch (UnsupportedEncodingException e)
- {
- // should never happen : TODO : log error
+ byteNewSuperior = newSuperior.getBytes("UTF-8");
+ length += byteNewSuperior.length + 1;
}
- return null;
+ else
+ length += 1;
+
+ if (newSuperiorId != null)
+ {
+ byteNewSuperiorId = newSuperiorId.getBytes("UTF-8");
+ length += byteNewSuperiorId.length + 1;
+ }
+ else
+ length += 1;
+
+ byte[] resultByteArray = encodeHeader(MSG_TYPE_MODIFYDN_REQUEST, length);
+ int pos = resultByteArray.length - length;
+
+ /* put the new RDN and a terminating 0 */
+ pos = addByteArray(byteNewRdn, resultByteArray, pos);
+
+ /* put the newsuperior and a terminating 0 */
+ if (newSuperior != null)
+ {
+ pos = addByteArray(byteNewSuperior, resultByteArray, pos);
+ }
+ else
+ resultByteArray[pos++] = 0;
+
+ /* put the newsuperiorId and a terminating 0 */
+ if (newSuperiorId != null)
+ {
+ pos = addByteArray(byteNewSuperiorId, resultByteArray, pos);
+ }
+ else
+ resultByteArray[pos++] = 0;
+
+ /* put the deleteoldrdn flag */
+ if (deleteOldRdn)
+ resultByteArray[pos++] = 1;
+ else
+ resultByteArray[pos++] = 0;
+
+ return resultByteArray;
}
/**
--
Gitblit v1.10.0