You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2018/06/07 13:29:11 UTC
[2/3] qpid-broker-j git commit: QPID-8202: [Broker-J] Address review
comments from Keith Wall
QPID-8202: [Broker-J] Address review comments from Keith Wall
(cherry picked from commit 9d08c765155f4d70e53f972f1a63b4a73cccc26f)
Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/daf346ef
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/daf346ef
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/daf346ef
Branch: refs/heads/7.0.x
Commit: daf346efcd5ca2652f49077c622a3ffccab03049
Parents: 0df1680
Author: Alex Rudyy <or...@apache.org>
Authored: Thu Jun 7 11:25:38 2018 +0100
Committer: Alex Rudyy <or...@apache.org>
Committed: Thu Jun 7 13:26:06 2018 +0100
----------------------------------------------------------------------
.../v0_8/ProtocolOutputConverterImpl.java | 52 +++++++++-----------
1 file changed, 22 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/daf346ef/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ProtocolOutputConverterImpl.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ProtocolOutputConverterImpl.java b/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ProtocolOutputConverterImpl.java
index bcc515b..10146cb 100644
--- a/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ProtocolOutputConverterImpl.java
+++ b/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/ProtocolOutputConverterImpl.java
@@ -176,29 +176,28 @@ public class ProtocolOutputConverterImpl implements ProtocolOutputConverter
}
else
{
- int maxBodySize = (int) _connection.getMaxFrameSize() - AMQFrame.getFrameOverhead();
-
-
- int capacity = bodySize > maxBodySize ? maxBodySize : bodySize;
-
- int writtenSize = capacity;
-
+ int maxFrameBodySize = (int) _connection.getMaxFrameSize() - AMQFrame.getFrameOverhead();
try (QpidByteBuffer contentByteBuffer = content.getContent())
{
- AMQBody firstContentBody = new MessageContentSourceBody(contentByteBuffer, 0, capacity);
-
- CompositeAMQBodyBlock
- compositeBlock =
- new CompositeAMQBodyBlock(channelId, deliverBody, contentHeaderBody, firstContentBody);
- writeFrame(compositeBlock);
+ int contentChunkSize = bodySize > maxFrameBodySize ? maxFrameBodySize : bodySize;
+ try (QpidByteBuffer chunk = contentByteBuffer.view(0, contentChunkSize))
+ {
+ writeFrame(new CompositeAMQBodyBlock(channelId,
+ deliverBody,
+ contentHeaderBody,
+ new MessageContentSourceBody(chunk)));
+ }
+ int writtenSize = contentChunkSize;
while (writtenSize < bodySize)
{
- capacity = bodySize - writtenSize > maxBodySize ? maxBodySize : bodySize - writtenSize;
- AMQBody body = new MessageContentSourceBody(contentByteBuffer, writtenSize, capacity);
- writtenSize += capacity;
-
- writeFrame(new AMQFrame(channelId, body));
+ contentChunkSize =
+ (bodySize - writtenSize) > maxFrameBodySize ? maxFrameBodySize : bodySize - writtenSize;
+ try (QpidByteBuffer chunk = contentByteBuffer.view(writtenSize, contentChunkSize))
+ {
+ writtenSize += contentChunkSize;
+ writeFrame(new AMQFrame(channelId, new MessageContentSourceBody(chunk)));
+ }
}
}
}
@@ -214,13 +213,11 @@ public class ProtocolOutputConverterImpl implements ProtocolOutputConverter
public static final byte TYPE = 3;
private final int _length;
private final QpidByteBuffer _content;
- private final int _offset;
- public MessageContentSourceBody(QpidByteBuffer content, int offset, int length)
+ private MessageContentSourceBody(QpidByteBuffer content)
{
_content = content;
- _offset = offset;
- _length = length;
+ _length = content.remaining();
}
@Override
@@ -238,13 +235,8 @@ public class ProtocolOutputConverterImpl implements ProtocolOutputConverter
@Override
public long writePayload(final ByteBufferSender sender)
{
- long size;
- try (final QpidByteBuffer content = _content.view(_offset, _length))
- {
- size = content.remaining();
- sender.send(content);
- }
- return size;
+ sender.send(_content);
+ return _length;
}
@Override
@@ -256,7 +248,7 @@ public class ProtocolOutputConverterImpl implements ProtocolOutputConverter
@Override
public String toString()
{
- return "[" + getClass().getSimpleName() + " offset: " + _offset + ", length: " + _length + "]";
+ return "[" + getClass().getSimpleName() + ", length: " + _length + "]";
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org