activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andytay...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-234 fix content-length for Stomp 1.0
Date Wed, 20 Jul 2016 12:42:11 GMT
ARTEMIS-234 fix content-length for Stomp 1.0


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/b466cce5
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/b466cce5
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/b466cce5

Branch: refs/heads/master
Commit: b466cce593bea6ab5ff9b2449c0fa724397a10e5
Parents: 413e7ae
Author: jbertram <jbertram@apache.org>
Authored: Tue Jul 19 16:09:06 2016 -0500
Committer: Andy Taylor <andy.tayls67@gmail.com>
Committed: Wed Jul 20 13:40:57 2016 +0100

----------------------------------------------------------------------
 .../activemq/artemis/core/protocol/stomp/StompFrame.java     | 3 ++-
 docs/user-manual/en/protocols-interoperability.md            | 8 ++++----
 .../activemq/artemis/tests/integration/stomp/StompTest.java  | 4 ++++
 .../artemis/tests/integration/stomp/v11/StompV11Test.java    | 2 ++
 4 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b466cce5/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 4e184db..27b222b 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
@@ -23,6 +23,7 @@ import java.util.Map;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
+import org.apache.activemq.artemis.core.protocol.stomp.v10.StompFrameV10;
 
 /**
  * Represents all the data in a STOMP frame.
@@ -107,7 +108,7 @@ public class StompFrame {
          head.append(Stomp.NEWLINE);
          // Output the headers.
          encodeHeaders(head);
-         if (bytesBody != null && bytesBody.length > 0 && !hasHeader(Stomp.Headers.CONTENT_LENGTH))
{
+         if (bytesBody != null && bytesBody.length > 0 && !hasHeader(Stomp.Headers.CONTENT_LENGTH)
&& !(this instanceof StompFrameV10)) {
             head.append(Stomp.Headers.CONTENT_LENGTH);
             head.append(Stomp.Headers.SEPARATOR);
             head.append(bytesBody.length);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b466cce5/docs/user-manual/en/protocols-interoperability.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/protocols-interoperability.md b/docs/user-manual/en/protocols-interoperability.md
index 5b486d0..7e81e65 100644
--- a/docs/user-manual/en/protocols-interoperability.md
+++ b/docs/user-manual/en/protocols-interoperability.md
@@ -384,18 +384,18 @@ destinations, the Stomp destinations must follow the same convention:
 Stomp is mainly a text-orientated protocol. To make it simpler to
 interoperate with JMS and Apache ActiveMQ Artemis Core API, our Stomp implementation
 checks for presence of the `content-length` header to decide how to map
-a Stomp message to a JMS Message or a Core message.
+a Stomp 1.0 message to a JMS Message or a Core message.
 
-If the Stomp message does *not* have a `content-length` header, it will
+If the Stomp 1.0 message does *not* have a `content-length` header, it will
 be mapped to a JMS *TextMessage* or a Core message with a *single
 nullable SimpleString in the body buffer*.
 
-Alternatively, if the Stomp message *has* a `content-length` header, it
+Alternatively, if the Stomp 1.0 message *has* a `content-length` header, it
 will be mapped to a JMS *BytesMessage* or a Core message with a *byte[]
 in the body buffer*.
 
 The same logic applies when mapping a JMS message or a Core message to
-Stomp. A Stomp client can check the presence of the `content-length`
+Stomp. A Stomp 1.0 client can check the presence of the `content-length`
 header to determine the type of the message body (String or bytes).
 
 #### Message IDs for Stomp messages

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b466cce5/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java
index f28f5b2..8ba369f 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java
@@ -595,6 +595,10 @@ public class StompTest extends StompTestBase {
       Assert.assertTrue(frame.indexOf("destination:") > 0);
       Assert.assertTrue(frame.indexOf(getName()) > 0);
 
+      Pattern cl = Pattern.compile("Content-length:\\s*(\\d+)", Pattern.CASE_INSENSITIVE);
+      Matcher cl_matcher = cl.matcher(frame);
+      Assert.assertFalse(cl_matcher.find());
+
       frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
       sendFrame(frame);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b466cce5/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java
index dfcd1b9..3d7e5f5 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java
@@ -2002,6 +2002,8 @@ public class StompV11Test extends StompV11TestBase {
 
       ClientStompFrame frame = connV11.receiveFrame();
 
+      assertEquals(getName().length(), Integer.parseInt(frame.getHeader("content-length")));
+
       this.ack(connV11, "sub1", frame);
 
       connV11.disconnect();


Mime
View raw message