Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x 6f8605693 -> d839d735f


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/d839d735
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d839d735
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d839d735

Branch: refs/heads/camel-2.16.x
Commit: d839d735f7dcc1546eb3866604fa73a8f3d39fb5
Parents: 6f86056
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:40:27 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/d839d735/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/d839d735/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/d839d735/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;
     }
 

Reply via email to