[
https://issues.apache.org/jira/browse/CAMEL-12827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16625121#comment-16625121
]
ASF GitHub Bot commented on CAMEL-12827:
----------------------------------------
davsclaus closed pull request #2528: CAMEL-12827 - HttpSendDynamicAware setting
port to -1 when not defined.
URL: https://github.com/apache/camel/pull/2528
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpSendDynamicAware.java
b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpSendDynamicAware.java
index 7968952c636..86fb192641a 100644
---
a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpSendDynamicAware.java
+++
b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpSendDynamicAware.java
@@ -141,7 +141,7 @@ public Processor createPostProcessor(Exchange exchange,
DynamicAwareEntry entry)
// if the path is just a trailing slash then skip it (eg it must
be longer than just the slash itself)
if (path != null && path.length() > 1) {
int port = parse.getPort();
- if (port != 80 && port != 443) {
+ if (port > 0 && port != 80 && port != 443) {
host += ":" + port;
}
if (!httpComponent) {
diff --git
a/components/camel-http-common/src/test/java/org/apache/camel/http/common/HttpSendDynamicAwareTest.java
b/components/camel-http-common/src/test/java/org/apache/camel/http/common/HttpSendDynamicAwareTest.java
new file mode 100644
index 00000000000..71ec8f51374
--- /dev/null
+++
b/components/camel-http-common/src/test/java/org/apache/camel/http/common/HttpSendDynamicAwareTest.java
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.http.common;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.apache.camel.spi.SendDynamicAware.DynamicAwareEntry;
+
+public class HttpSendDynamicAwareTest {
+
+ private HttpSendDynamicAware httpSendDynamicAware;
+ @Before
+ public void setUp() throws Exception {
+ this.httpSendDynamicAware = new HttpSendDynamicAware();
+
+ }
+
+ @Test
+ public void testHttpUndefinedPortWithPathParseUri() {
+ this.httpSendDynamicAware.setScheme("http");
+ DynamicAwareEntry entry = new
DynamicAwareEntry("http://localhost/test", null, null);
+ String[] result = httpSendDynamicAware.parseUri(entry);
+ assertEquals("Parse should not add port if http and not specified",
"localhost", result[0]);
+ }
+
+ @Test
+ public void testHttpsUndefinedPortParseUri() {
+ this.httpSendDynamicAware.setScheme("https");
+ DynamicAwareEntry entry = new
DynamicAwareEntry("https://localhost/test", null, null);
+ String[] result = httpSendDynamicAware.parseUri(entry);
+ assertEquals("Parse should not add port if https and not specified",
"localhost", result[0]);
+ }
+
+ @Test
+ public void testHttp4UndefinedPortWithPathParseUri() {
+ this.httpSendDynamicAware.setScheme("http4");
+ DynamicAwareEntry entry = new
DynamicAwareEntry("http4://localhost/test", null, null);
+ String[] result = httpSendDynamicAware.parseUri(entry);
+ assertEquals("Parse should not add port if http4 and not specified",
"localhost", result[0]);
+ }
+
+ @Test
+ public void testHttps4UndefinedPortParseUri() {
+ this.httpSendDynamicAware.setScheme("https4");
+ DynamicAwareEntry entry = new
DynamicAwareEntry("https4://localhost/test", null, null);
+ String[] result = httpSendDynamicAware.parseUri(entry);
+ assertEquals("Parse should not add port if https4 and not specified",
"localhost", result[0]);
+ }
+
+ @Test
+ public void testHttpPort80ParseUri() {
+ this.httpSendDynamicAware.setScheme("http");
+ DynamicAwareEntry entry = new
DynamicAwareEntry("http://localhost:80/test", null, null);
+ String[] result = httpSendDynamicAware.parseUri(entry);
+ assertEquals("Parse should not port if http and port 80 specified",
"localhost", result[0]);
+ }
+
+ @Test
+ public void testHttpsPort443ParseUri() {
+ this.httpSendDynamicAware.setScheme("https");
+ DynamicAwareEntry entry = new
DynamicAwareEntry("https://localhost:443/test", null, null);
+ String[] result = httpSendDynamicAware.parseUri(entry);
+ assertEquals("Parse should not port if https and port 443 specified",
"localhost", result[0]);
+ }
+
+ @Test
+ public void testHttpPort8080ParseUri() {
+ this.httpSendDynamicAware.setScheme("http");
+ DynamicAwareEntry entry = new
DynamicAwareEntry("http://localhost:8080/test", null, null);
+ String[] result = httpSendDynamicAware.parseUri(entry);
+ assertEquals("Parse should add port if http and port other than 80
specified", "localhost:8080", result[0]);
+ }
+
+ @Test
+ public void testHttpsPort8443ParseUri() {
+ this.httpSendDynamicAware.setScheme("https");
+ DynamicAwareEntry entry = new
DynamicAwareEntry("https://localhost:8443/test", null, null);
+ String[] result = httpSendDynamicAware.parseUri(entry);
+ assertEquals("Parse should add port if https and port other than 443
specified", "localhost:8443", result[0]);
+ }
+
+}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> camel-http-common HttpSendDynamicAware setting port to -1 when port is not
> defined in uri
> -----------------------------------------------------------------------------------------
>
> Key: CAMEL-12827
> URL: https://issues.apache.org/jira/browse/CAMEL-12827
> Project: Camel
> Issue Type: Bug
> Components: camel-http-common
> Affects Versions: 2.22.0, 2.22.1, 2.23.0
> Reporter: Bob Paulin
> Priority: Major
> Fix For: 2.22.2, 2.23.0
>
>
> If the route qualifies for SendDyanamicAware processing within the camel-http
> or camel-http4 component and the route does not specify a port it is getting
> set to -1. This should simply assume port 80 or 443 based on http vs https.
> Logic exists to trim those ports if they are specified however if you omit
> them your get the following exception:
>
> {code:java}
> 2018-09-21T16:20:32,797 | ERROR | Camel (camel-2) thread #10 -
> NettyEventExecutorGroup | AbstractErrorListProcessor | 26 -
> com.somebundle - 1.0.76 | Error Handled for route:
> http://0.0.0.0:8880/%7BsiteId%7D/%7Bcountry%7D/somepath?httpMethodRestrict=GET
> org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint:
> https4://somedomain.com:-1?bridgeEndpoint=true due to: Expected
> scheme-specific part at index 6: https:
> at
> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:758)
> ~[91:org.apache.camel.camel-core:2.22.0]
> at
> org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:80)
> ~[91:org.apache.camel.camel-core:2.22.0]
> at
> org.apache.camel.util.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:91)
> ~[91:org.apache.camel.camel-core:2.22.0]
> at
> org.apache.camel.processor.SendDynamicProcessor.resolveEndpoint(SendDynamicProcessor.java:239)
> ~[91:org.apache.camel.camel-core:2.22.0]
> at
> org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:132)
> ~[91:org.apache.camel.camel-core:2.22.0]
> at
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:181)
> ~[91:org.apache.camel.camel-core:2.22.0]
> at
> org.apache.camel.processor.InterceptorToAsyncProcessorBridge.process(InterceptorToAsyncProcessorBridge.java:67)
> ~[91:org.apache.camel.camel-core:2.22.0]{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)