You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2019/12/15 19:06:01 UTC
[camel] branch camel-3.0.x updated: PR-3402: Strip both forms of
prefixes from namedReplyTo
This is an automated email from the ASF dual-hosted git repository.
janbednar pushed a commit to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.0.x by this push:
new 53839a3 PR-3402: Strip both forms of prefixes from namedReplyTo
53839a3 is described below
commit 53839a3fb5bc141bafce58aeab18ed79d2943d86
Author: Roni Polus <ro...@connexta.com>
AuthorDate: Wed Dec 11 18:26:08 2019 -0700
PR-3402: Strip both forms of prefixes from namedReplyTo
(cherry picked from commit 3cbe3a840eabe35154b89a7ac9591f139fc5d485)
---
.../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());