CAMEL-6946: Use ConnectException if netty producer cannot connect to remote 
server.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/67c63ee2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/67c63ee2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/67c63ee2

Branch: refs/heads/camel-2.11.x
Commit: 67c63ee26ea7c112805b566ed05b97375a2243ac
Parents: a3f51b8
Author: Claus Ibsen <davscl...@apache.org>
Authored: Fri Nov 8 11:32:41 2013 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Fri Nov 8 11:33:24 2013 +0100

----------------------------------------------------------------------
 .../java/org/apache/camel/component/netty/NettyProducer.java  | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/67c63ee2/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
index a6c5a7e..65b1800 100644
--- 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
+++ 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.netty;
 
+import java.net.ConnectException;
 import java.net.InetSocketAddress;
 import java.util.Map;
 import java.util.concurrent.CountDownLatch;
@@ -403,7 +404,11 @@ public class NettyProducer extends DefaultAsyncProducer {
         
 
         if (!channelFuture.isDone() || !channelFuture.isSuccess()) {
-            throw new CamelException("Cannot connect to " + 
configuration.getAddress(), channelFuture.getCause());
+            ConnectException cause = new ConnectException("Cannot connect to " 
+ configuration.getAddress());
+            if (channelFuture.getCause() != null) {
+                cause.initCause(channelFuture.getCause());
+            }
+            throw cause;
         }
         Channel answer = channelFuture.getChannel();
         // to keep track of all channels in use

Reply via email to