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/AddMsg.java | 67 +++++++++++++++------------------
1 files changed, 31 insertions(+), 36 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/protocol/AddMsg.java b/opends/src/server/org/opends/server/replication/protocol/AddMsg.java
index 5979842..299bcfa 100644
--- a/opends/src/server/org/opends/server/replication/protocol/AddMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/AddMsg.java
@@ -211,48 +211,43 @@
/**
* Get the byte[] 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
+ int length = encodedAttributes.length;
+ byte[] byteParentId = null;
+ if (parentUniqueId != null)
{
- int length = encodedAttributes.length;
- byte[] byteParentId = null;
- if (parentUniqueId != null)
- {
- byteParentId = parentUniqueId.getBytes("UTF-8");
- length += byteParentId.length + 1;
- }
- else
- {
- length += 1;
- }
-
- /* encode the header in a byte[] large enough to also contain the mods */
- byte [] resultByteArray = encodeHeader(MSG_TYPE_ADD_REQUEST, length);
-
- int pos = resultByteArray.length - length;
-
- if (byteParentId != null)
- pos = addByteArray(byteParentId, resultByteArray, pos);
- else
- resultByteArray[pos++] = 0;
-
- /* put the attributes */
- for (int i=0; i<encodedAttributes.length; i++,pos++)
- {
- resultByteArray[pos] = encodedAttributes[i];
- }
- return resultByteArray;
- } catch (UnsupportedEncodingException e)
- {
- // this can not happen as only UTF-8 is used and it is always
- // going to be supported by the jvm
- // TODO : should log an error
- return null;
+ byteParentId = parentUniqueId.getBytes("UTF-8");
+ length += byteParentId.length + 1;
}
+ else
+ {
+ length += 1;
+ }
+
+ /* encode the header in a byte[] large enough to also contain the mods */
+ byte [] resultByteArray = encodeHeader(MSG_TYPE_ADD_REQUEST, length);
+
+ int pos = resultByteArray.length - length;
+
+ if (byteParentId != null)
+ pos = addByteArray(byteParentId, resultByteArray, pos);
+ else
+ resultByteArray[pos++] = 0;
+
+ /* put the attributes */
+ for (int i=0; i<encodedAttributes.length; i++,pos++)
+ {
+ resultByteArray[pos] = encodedAttributes[i];
+ }
+ return resultByteArray;
}
/**
--
Gitblit v1.10.0