implement toByteSequence on direct byte buffers too.. needed for http://issues.apache.org/activemq/browse/AMQ-907

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@439108 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2006-09-01 00:00:49 +00:00
parent 9d4c74fb74
commit 1c0de6bda4
1 changed files with 6 additions and 2 deletions

View File

@ -222,9 +222,13 @@ final public class ByteBufferPacket implements Packet {
if( buffer.hasArray() ) {
byte[] bs = buffer.array();
return new ByteSequence(bs, buffer.position(), buffer.remaining());
} else {
byte[] bs = new byte[buffer.remaining()];
int p = buffer.position();
buffer.get(bs);
buffer.position(p);
return new ByteSequence(bs, 0, bs.length);
}
// TODO: implement the direct case.
return null;
}
/**