This is an automated email from the ASF dual-hosted git repository. janbednar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 3cbe3a8 PR-3402: Strip both forms of prefixes from namedReplyTo 3cbe3a8 is described below commit 3cbe3a840eabe35154b89a7ac9591f139fc5d485 Author: Roni Polus <roni.po...@connexta.com> AuthorDate: Wed Dec 11 18:26:08 2019 -0700 PR-3402: Strip both forms of prefixes from namedReplyTo --- .../sjms/jms/DefaultDestinationCreationStrategy.java | 16 ++++++++-------- .../sjms/jms/DefaultDestinationCreationStrategyTest.java | 8 ++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/DefaultDestinationCreationStrategy.java b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/DefaultDestinationCreationStrategy.java index 494fc81..f4a129c 100644 --- a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/DefaultDestinationCreationStrategy.java +++ b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/DefaultDestinationCreationStrategy.java @@ -20,6 +20,8 @@ import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Session; +import org.apache.camel.util.URISupport; + /** * Default implementation of DestinationCreationStrategy, delegates to Session.createTopic * and Session.createQueue. @@ -28,23 +30,21 @@ import javax.jms.Session; * @see javax.jms.Session */ public class DefaultDestinationCreationStrategy implements DestinationCreationStrategy { - private static final String TOPIC_PREFIX = "topic://"; - private static final String QUEUE_PREFIX = "queue://"; @Override public Destination createDestination(final Session session, String name, final boolean topic) throws JMSException { Destination destination; + if (topic) { - if (name.startsWith(TOPIC_PREFIX)) { - name = name.substring(TOPIC_PREFIX.length()); - } + name = URISupport.stripPrefix(name, "topic://"); + name = URISupport.stripPrefix(name, "topic:"); destination = session.createTopic(name); } else { - if (name.startsWith(QUEUE_PREFIX)) { - name = name.substring(QUEUE_PREFIX.length()); - } + name = URISupport.stripPrefix(name, "queue://"); + name = URISupport.stripPrefix(name, "queue:"); destination = session.createQueue(name); } + return destination; } diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/jms/DefaultDestinationCreationStrategyTest.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/jms/DefaultDestinationCreationStrategyTest.java index 2187320..a61080d 100644 --- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/jms/DefaultDestinationCreationStrategyTest.java +++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/jms/DefaultDestinationCreationStrategyTest.java @@ -34,6 +34,10 @@ public class DefaultDestinationCreationStrategyTest extends JmsTestSupport { assertNotNull(destination); assertEquals("test", destination.getQueueName()); + destination = (Queue)strategy.createDestination(getSession(), "queue:test", false); + assertNotNull(destination); + assertEquals("test", destination.getQueueName()); + destination = (Queue)strategy.createDestination(getSession(), "test", false); assertNotNull(destination); assertEquals("test", destination.getQueueName()); @@ -45,6 +49,10 @@ public class DefaultDestinationCreationStrategyTest extends JmsTestSupport { assertNotNull(destination); assertEquals("test", destination.getTopicName()); + destination = (Topic)strategy.createDestination(getSession(), "topic:test", true); + assertNotNull(destination); + assertEquals("test", destination.getTopicName()); + destination = (Topic)strategy.createDestination(getSession(), "test", true); assertNotNull(destination); assertEquals("test", destination.getTopicName());