Repository: camel Updated Branches: refs/heads/master 33fd28174 -> 62d6fa52a
CAMEL-9247: netty4-http - Use port 80 if no port number configured Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/62d6fa52 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/62d6fa52 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/62d6fa52 Branch: refs/heads/master Commit: 62d6fa52ab5ca8f1743625fd477f4783e52c97ae Parents: 33fd281 Author: Andrea Cosentino <anco...@gmail.com> Authored: Wed Nov 4 17:01:32 2015 +0100 Committer: Andrea Cosentino <anco...@gmail.com> Committed: Wed Nov 4 17:39:25 2015 +0100 ---------------------------------------------------------------------- .../apache/camel/component/netty/http/NettyHttpComponent.java | 6 ++++++ .../org/apache/camel/component/netty/http/BaseNettyTest.java | 1 - .../apache/camel/component/netty4/http/NettyHttpComponent.java | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/62d6fa52/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java index a9d8c27..59fcc91 100644 --- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java +++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java @@ -58,6 +58,9 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt private HeaderFilterStrategy headerFilterStrategy; private NettyHttpSecurityConfiguration securityConfiguration; + // If the port is not specified Netty set it to -1, we need to set it on a default port in this case + private int defaultPortIfNotProvided = 80; + public NettyHttpComponent() { // use the http configuration and filter strategy super(NettyHttpEndpoint.class); @@ -166,6 +169,9 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt ((NettyHttpConfiguration) configuration).setPath(uri.getPath()); } + if (configuration.getPort() == -1) { + configuration.setPort(defaultPortIfNotProvided); + } return configuration; } http://git-wip-us.apache.org/repos/asf/camel/blob/62d6fa52/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/BaseNettyTest.java ---------------------------------------------------------------------- diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/BaseNettyTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/BaseNettyTest.java index 40a127c..0f8f7e7 100644 --- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/BaseNettyTest.java +++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/BaseNettyTest.java @@ -49,7 +49,6 @@ public class BaseNettyTest extends CamelTestSupport { // use next free port port = AvailablePortFinder.getNextAvailable(port + 1); } - } @AfterClass http://git-wip-us.apache.org/repos/asf/camel/blob/62d6fa52/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java index 82f783d..50d281c 100644 --- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java +++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java @@ -57,6 +57,9 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt private NettyHttpBinding nettyHttpBinding; private HeaderFilterStrategy headerFilterStrategy; private NettyHttpSecurityConfiguration securityConfiguration; + + // If the port is not specified Netty set it to -1, we need to set it on a default port in this case + private int defaultPortIfNotProvided = 80; public NettyHttpComponent() { // use the http configuration and filter strategy @@ -174,6 +177,9 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt ((NettyHttpConfiguration) configuration).setPath(uri.getPath()); } + if (configuration.getPort() == -1) { + configuration.setPort(defaultPortIfNotProvided); + } return configuration; }