Make a best effort to find the correct destination name even if space padded before falling back to the fallback conversion config. 

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1344894 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2012-05-31 20:26:28 +00:00
parent fd37e8c883
commit eb887f1545
1 changed files with 11 additions and 6 deletions

View File

@ -54,7 +54,6 @@ public class LegacyFrameTranslator implements FrameTranslator {
if(intendedType.equalsIgnoreCase("text")){
ActiveMQTextMessage text = new ActiveMQTextMessage();
try {
//text.setText(new String(command.getContent(), "UTF-8"));
ByteArrayOutputStream bytes = new ByteArrayOutputStream(command.getContent().length + 4);
DataOutputStream data = new DataOutputStream(bytes);
data.writeInt(command.getContent().length);
@ -79,7 +78,6 @@ public class LegacyFrameTranslator implements FrameTranslator {
} else {
ActiveMQTextMessage text = new ActiveMQTextMessage();
try {
//text.setText(new String(command.getContent(), "UTF-8"));
ByteArrayOutputStream bytes = new ByteArrayOutputStream(command.getContent().length + 4);
DataOutputStream data = new DataOutputStream(bytes);
data.writeInt(command.getContent().length);
@ -173,7 +171,14 @@ public class LegacyFrameTranslator implements FrameTranslator {
public ActiveMQDestination convertDestination(ProtocolConverter converter, String name, boolean forceFallback) throws ProtocolException {
if (name == null) {
return null;
} else if (name.startsWith("/queue/")) {
}
// in case of space padding by a client we trim for the initial detection, on fallback use
// the un-trimmed value.
String originalName = name;
name = name.trim();
if (name.startsWith("/queue/")) {
String qName = name.substring("/queue/".length(), name.length());
return ActiveMQDestination.createDestination(qName, ActiveMQDestination.QUEUE_TYPE);
} else if (name.startsWith("/topic/")) {
@ -192,16 +197,16 @@ public class LegacyFrameTranslator implements FrameTranslator {
} else {
if (forceFallback) {
try {
ActiveMQDestination fallback = ActiveMQDestination.getUnresolvableDestinationTransformer().transform(name);
ActiveMQDestination fallback = ActiveMQDestination.getUnresolvableDestinationTransformer().transform(originalName);
if (fallback != null) {
return fallback;
}
} catch (JMSException e) {
throw new ProtocolException("Illegal destination name: [" + name + "] -- ActiveMQ STOMP destinations "
throw new ProtocolException("Illegal destination name: [" + originalName + "] -- ActiveMQ STOMP destinations "
+ "must begin with one of: /queue/ /topic/ /temp-queue/ /temp-topic/", false, e);
}
}
throw new ProtocolException("Illegal destination name: [" + name + "] -- ActiveMQ STOMP destinations "
throw new ProtocolException("Illegal destination name: [" + originalName + "] -- ActiveMQ STOMP destinations "
+ "must begin with one of: /queue/ /topic/ /temp-queue/ /temp-topic/");
}
}