[ http://issues.apache.org/jira/browse/DIRMINA-199?page=all ]
Zohar Amir closed DIRMINA-199.
------------------------------
We use it this way:
try {
part1 = getPart1(in);
part2 = getpart2in);
byte byte1 = in.get();
byte byte2 = in.get();
byte byte3 = in.get();
byte[] messageTypeBytes = getTlv(in, CONTENT_TYPE_TAG);
int messageTypeCode = byteArrayToInt(messageTypeBytes);
messageType =
MessageType.getMessageType(messageTypeCode);
if(messageType == null) {
throw new DecoderException("unknown message
type code " + messageTypeCode);
}
// TODO see if we can avoid using arrays and stay with
the buffer
int contentLength = byteArrayToInt(getTlv(in,
CONTENT_LENGTH_TAG));
if (contentLength > 0) {
byte[] contentBytes = new byte[contentLength];
in.get(contentBytes);
contentBuffer =
ByteBuffer.allocate(contentLength);
contentBuffer.put(contentBytes);
contentBuffer.flip();
}
} catch (BufferUnderflowException e) {
in.rewind();
return false;
}
But I think your example is OK
> CumulativeProtocolDecoder javadoc example
> -----------------------------------------
>
> Key: DIRMINA-199
> URL: http://issues.apache.org/jira/browse/DIRMINA-199
> Project: Directory MINA
> Issue Type: Bug
> Affects Versions: 0.9.2
> Reporter: Zohar Amir
> Assigned To: Niklas Therning
> Priority: Minor
> Fix For: 1.0
>
>
> I think that the example given in the CumulativeProtocolDecoder's javadoc is
> a bit too simplistic. I think the example should include some reading from
> the buffer, so that it can demonstrate the need to rewind it before returning
> 'false'.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira