mirror of https://github.com/apache/activemq.git
fix bug in fragmentation
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@384638 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7b69145159
commit
3d7f76719f
|
@ -179,7 +179,6 @@ public class CommandChannel implements Service {
|
||||||
|
|
||||||
public void write(Command command, SocketAddress address) throws IOException {
|
public void write(Command command, SocketAddress address) throws IOException {
|
||||||
synchronized (writeLock) {
|
synchronized (writeLock) {
|
||||||
header.incrementCounter();
|
|
||||||
|
|
||||||
ByteArrayOutputStream largeBuffer = new ByteArrayOutputStream(largeMessageBufferSize);
|
ByteArrayOutputStream largeBuffer = new ByteArrayOutputStream(largeMessageBufferSize);
|
||||||
wireFormat.marshal(command, new DataOutputStream(largeBuffer));
|
wireFormat.marshal(command, new DataOutputStream(largeBuffer));
|
||||||
|
@ -187,6 +186,7 @@ public class CommandChannel implements Service {
|
||||||
int size = data.length;
|
int size = data.length;
|
||||||
|
|
||||||
if (size < datagramSize) {
|
if (size < datagramSize) {
|
||||||
|
header.incrementCounter();
|
||||||
header.setPartial(false);
|
header.setPartial(false);
|
||||||
header.setComplete(true);
|
header.setComplete(true);
|
||||||
header.setDataSize(size);
|
header.setDataSize(size);
|
||||||
|
@ -210,6 +210,10 @@ public class CommandChannel implements Service {
|
||||||
writeBuffer.rewind();
|
writeBuffer.rewind();
|
||||||
int chunkSize = writeBuffer.capacity() - headerMarshaller.getHeaderSize(header);
|
int chunkSize = writeBuffer.capacity() - headerMarshaller.getHeaderSize(header);
|
||||||
lastFragment = offset + chunkSize >= length;
|
lastFragment = offset + chunkSize >= length;
|
||||||
|
if (lastFragment) {
|
||||||
|
chunkSize = length - offset;
|
||||||
|
}
|
||||||
|
header.incrementCounter();
|
||||||
header.setDataSize(chunkSize);
|
header.setDataSize(chunkSize);
|
||||||
header.setComplete(lastFragment);
|
header.setComplete(lastFragment);
|
||||||
headerMarshaller.writeHeader(header, writeBuffer);
|
headerMarshaller.writeHeader(header, writeBuffer);
|
||||||
|
|
Loading…
Reference in New Issue