Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id AEE46200B85 for ; Thu, 15 Sep 2016 15:27:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id ADAE3160ADA; Thu, 15 Sep 2016 13:27:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 08137160AB5 for ; Thu, 15 Sep 2016 15:27:05 +0200 (CEST) Received: (qmail 85139 invoked by uid 500); 15 Sep 2016 13:27:05 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 85031 invoked by uid 99); 15 Sep 2016 13:27:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Sep 2016 13:27:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0AE88E09AC; Thu, 15 Sep 2016 13:27:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: clebertsuconic@apache.org To: commits@activemq.apache.org Date: Thu, 15 Sep 2016 13:27:05 -0000 Message-Id: <5ba14aa714de468ba03362429803bfef@git.apache.org> In-Reply-To: <0aeb61d2cc784db48581910dbfe1fdbf@git.apache.org> References: <0aeb61d2cc784db48581910dbfe1fdbf@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/3] activemq-artemis git commit: STOMP frame encode: Use fixed buffers archived-at: Thu, 15 Sep 2016 13:27:06 -0000 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ä Authored: Wed Sep 14 20:53:27 2016 +0300 Committer: Ville Skyttä 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); }