From 6199d4ee110e090bd0e54560b11f17bb114e2211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 13 Jul 2015 23:13:41 +0300 Subject: [PATCH 1/2] Don't hardcode supported STOMP versions but loop through StompVersions --- .../artemis/core/protocol/stomp/StompProtocolManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java index 7728a3f4d2..b9c36c1abd 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java @@ -379,7 +379,12 @@ class StompProtocolManager implements ProtocolManager, No public String getSupportedVersionsAsString() { - return "v" + StompVersions.V1_0 + " v" + StompVersions.V1_1 + " v" + StompVersions.V1_2; + String versions = ""; + for (StompVersions version : StompVersions.values()) + { + versions += " v" + version; + } + return versions.substring(1); } public String getVirtualHostName() From 9e41d961beaa0a8bf76514afd8715d61560b8286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 13 Jul 2015 23:16:55 +0300 Subject: [PATCH 2/2] Send supported versions back in STOMP ERROR version https://stomp.github.io/stomp-specification-1.2.html#Protocol_Negotiation --- .../artemis/core/protocol/stomp/StompConnection.java | 2 +- .../core/protocol/stomp/StompProtocolManager.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java index f172b39d42..cf67df4402 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java @@ -491,7 +491,7 @@ public final class StompConnection implements RemotingConnection { //not a supported version! ActiveMQStompException error = BUNDLE.versionNotSupported(acceptVersion); - error.addHeader(Stomp.Headers.Error.VERSION, acceptVersion); + error.addHeader(Stomp.Headers.Error.VERSION, manager.getSupportedVersionsAsErrorVersion()); error.addHeader(Stomp.Headers.CONTENT_TYPE, "text/plain"); error.setBody("Supported protocol versions are " + manager.getSupportedVersionsAsString()); error.setDisconnect(true); diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java index b9c36c1abd..fa9d0c01f9 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java @@ -387,6 +387,16 @@ class StompProtocolManager implements ProtocolManager, No return versions.substring(1); } + public String getSupportedVersionsAsErrorVersion() + { + String versions = ""; + for (StompVersions version : StompVersions.values()) + { + versions += "," + version; + } + return versions.substring(1); + } + public String getVirtualHostName() { return "activemq";