Author: clebert.suconic(a)jboss.com
Date: 2011-11-21 09:36:50 -0500 (Mon, 21 Nov 2011)
New Revision: 11725
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/stomp/StompTest.java
Log:
Stomp to throw exception on inexistent destination = HORNETQ-799
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java
===================================================================
---
branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java 2011-11-21
14:15:17 UTC (rev 11724)
+++
branches/Branch_2_2_AS7/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java 2011-11-21
14:36:50 UTC (rev 11725)
@@ -61,6 +61,8 @@
// Attributes ----------------------------------------------------
private final HornetQServer server;
+
+ private final SimpleString managementAddress;
private final Executor executor;
@@ -106,6 +108,7 @@
public StompProtocolManager(final HornetQServer server, final List<Interceptor>
interceptors)
{
this.server = server;
+ this.managementAddress = server.getConfiguration().getManagementAddress();
this.executor = server.getExecutorFactory().getExecutor();
}
@@ -341,6 +344,8 @@
}
subscriptionID = "subscription/" + destination;
}
+
+ validateDestination(new SimpleString(destination));
StompSession stompSession = getSession(connection);
stompSession.setNoLocal(noLocal);
if (stompSession.containsSubscription(subscriptionID))
@@ -583,10 +588,15 @@
*/
private void validateDestination(SimpleString address) throws Exception,
HornetQException
{
- Bindings binding = server.getPostOffice().lookupBindingsForAddress(address);
- if (binding == null || binding.getBindings().size() == 0)
+ if (!address.equals(managementAddress))
{
- throw new HornetQException(HornetQException.ADDRESS_DOES_NOT_EXIST,
"Address " + address + " has not been deployed");
+ Bindings binding = server.getPostOffice().lookupBindingsForAddress(address);
+ if (binding == null || binding.getBindings().size() == 0)
+ {
+ throw new HornetQException(HornetQException.ADDRESS_DOES_NOT_EXIST,
"Address " + address +
+ "
has not been deployed");
+ }
+
}
}
Modified:
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/stomp/StompTest.java
===================================================================
---
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/stomp/StompTest.java 2011-11-21
14:15:17 UTC (rev 11724)
+++
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/stomp/StompTest.java 2011-11-21
14:36:50 UTC (rev 11725)
@@ -1061,6 +1061,29 @@
sendFrame(frame);
}
+ public void testSubscribeToInvalidTopic() throws Exception
+ {
+
+ String frame = "CONNECT\n" + "login: brianm\n" +
"passcode: wombats\n\n" + Stomp.NULL;
+ sendFrame(frame);
+
+ frame = receiveFrame(100000);
+ Assert.assertTrue(frame.startsWith("CONNECTED"));
+
+ frame = "SUBSCRIBE\n" + "destination:" +
+ getTopicPrefix() +
+ getTopicName()+"IDontExist" +
+ "\n" +
+ "receipt: 12\n" +
+ "\n\n" +
+ Stomp.NULL;
+ sendFrame(frame);
+ frame = receiveFrame(10000);
+
+ System.out.println(frame);
+ Assert.assertTrue(frame.startsWith("ERROR"));
+ }
+
public void testDurableSubscriberWithReconnection() throws Exception
{