This is an automated email from the ASF dual-hosted git repository.

davsclaus 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 207732a  CAMEL-13542: Fixed camel-catalog would strip out dashes in 
hostnames when using optimized toD with http components.
207732a is described below

commit 207732a489affc2fe5335c6d7aa0d54dbf463da5
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu May 16 11:08:40 2019 +0200

    CAMEL-13542: Fixed camel-catalog would strip out dashes in hostnames when 
using optimized toD with http components.
---
 .../java/org/apache/camel/catalog/CamelCatalogTest.java  | 16 ++++++++++++++++
 .../camel/runtimecatalog/impl/AbstractCamelCatalog.java  |  5 +++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git 
a/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
 
b/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
index 1a84811..fc1d14d 100644
--- 
a/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
+++ 
b/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
@@ -335,6 +335,22 @@ public class CamelCatalogTest {
     }
 
     @Test
+    public void testNetty4Http4DynamicToIssueHost() throws Exception {
+        String uri = "netty4-http:http://a-b-c.hostname.tld:8080/anything";;
+        Map<String, String> params = catalog.endpointProperties(uri);
+        assertEquals("http", params.get("protocol"));
+        assertEquals("a-b-c.hostname.tld", params.get("host"));
+        assertEquals("8080", params.get("port"));
+        assertEquals("anything", params.get("path"));
+
+        // remove path
+        params.remove("path");
+
+        String resolved = catalog.asEndpointUri("netty4-http", params, false);
+        assertEquals("netty4-http:http:a-b-c.hostname.tld:8080", resolved);
+    }
+
+    @Test
     public void testEndpointProperties() throws Exception {
         Map<String, String> map = 
catalog.endpointProperties("ftp:someserver:21/foo?connectTimeout=5000");
         assertNotNull(map);
diff --git 
a/core/camel-base/src/main/java/org/apache/camel/runtimecatalog/impl/AbstractCamelCatalog.java
 
b/core/camel-base/src/main/java/org/apache/camel/runtimecatalog/impl/AbstractCamelCatalog.java
index 1023876..b42967b 100644
--- 
a/core/camel-base/src/main/java/org/apache/camel/runtimecatalog/impl/AbstractCamelCatalog.java
+++ 
b/core/camel-base/src/main/java/org/apache/camel/runtimecatalog/impl/AbstractCamelCatalog.java
@@ -74,6 +74,7 @@ public abstract class AbstractCamelCatalog {
     // CHECKSTYLE:OFF
 
     private static final Pattern SYNTAX_PATTERN = Pattern.compile("([\\w.]+)");
+    private static final Pattern SYNTAX_DASH_PATTERN = 
Pattern.compile("([\\w.-]+)");
     private static final Pattern COMPONENT_SYNTAX_PARSER = 
Pattern.compile("([^\\w-]*)([\\w-]+)");
 
     private SuggestionStrategy suggestionStrategy;
@@ -949,7 +950,7 @@ public abstract class AbstractCamelCatalog {
             // oh darn some options is missing, so we need a complex way of 
building the uri
 
             // the tokens between the options in the path
-            String[] tokens = syntax.split("[\\w.]+");
+            String[] tokens = SYNTAX_DASH_PATTERN.split(syntax);
 
             // parse the syntax into each options
             Matcher matcher = SYNTAX_PATTERN.matcher(originalSyntax);
@@ -965,7 +966,7 @@ public abstract class AbstractCamelCatalog {
             syntax = syntax.replaceAll("\\}\\}", "ENDCAMELPLACEHOLDER");
 
             // parse the syntax into each options
-            Matcher matcher2 = SYNTAX_PATTERN.matcher(syntax);
+            Matcher matcher2 = SYNTAX_DASH_PATTERN.matcher(syntax);
             List<String> options2 = new ArrayList<>();
             while (matcher2.find()) {
                 String s = matcher2.group(1);

Reply via email to