You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2016/09/15 13:27:05 UTC
[2/3] activemq-artemis git commit: STOMP frame encode: Use fixed
buffers
STOMP frame encode: Use fixed buffers
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/2c7c81ca
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/2c7c81ca
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/2c7c81ca
Branch: refs/heads/master
Commit: 2c7c81ca9ea305ff3e34e4f0158ffbb46550dec2
Parents: 8e59cf4
Author: Ville Skytt� <vi...@iki.fi>
Authored: Wed Sep 14 20:53:27 2016 +0300
Committer: Ville Skytt� <vi...@iki.fi>
Committed: Wed Sep 14 20:54:28 2016 +0300
----------------------------------------------------------------------
.../artemis/core/protocol/stomp/StompFrame.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2c7c81ca/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java
index 044b2db..5dd74f5 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompFrame.java
@@ -91,15 +91,10 @@ public class StompFrame {
public ActiveMQBuffer toActiveMQBuffer() throws Exception {
if (buffer == null) {
- if (bytesBody != null) {
- buffer = ActiveMQBuffers.dynamicBuffer(bytesBody.length + 512);
- }
- else {
- buffer = ActiveMQBuffers.dynamicBuffer(512);
- }
-
if (isPing()) {
- buffer.writeByte((byte) 10);
+ buffer = ActiveMQBuffers.fixedBuffer(1);
+ buffer.writeByte((byte)10);
+ size = buffer.writerIndex();
return buffer;
}
@@ -117,7 +112,12 @@ public class StompFrame {
// Add a newline to separate the headers from the content.
head.append(Stomp.NEWLINE);
- buffer.writeBytes(head.toString().getBytes(StandardCharsets.UTF_8));
+ byte[] headBytes = head.toString().getBytes(StandardCharsets.UTF_8);
+ int bodyLength = (bytesBody == null) ? 0 : bytesBody.length;
+
+ buffer = ActiveMQBuffers.fixedBuffer(headBytes.length + bodyLength + END_OF_FRAME.length);
+
+ buffer.writeBytes(headBytes);
if (bytesBody != null) {
buffer.writeBytes(bytesBody);
}