Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2011-03-31 14:33:11 +0000
committerSimone Bordet2011-03-31 14:33:11 +0000
commit215bf562aaa3353787c2e963c5b09ea39274f3b1 (patch)
tree3cce45a8f69758f3048229d1ba16cf60247abd7a
parentf7a0d7d134f2e568e22aa06a67d17bb679554382 (diff)
downloadorg.eclipse.jetty.project-215bf562aaa3353787c2e963c5b09ea39274f3b1.tar.gz
org.eclipse.jetty.project-215bf562aaa3353787c2e963c5b09ea39274f3b1.tar.xz
org.eclipse.jetty.project-215bf562aaa3353787c2e963c5b09ea39274f3b1.zip
Improved exception handling during connect to remote server.
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2942 7e9141cc-0065-0410-87d8-b60c137991c4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java28
1 files changed, 22 insertions, 6 deletions
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java
index 5ba8c8309c..e59e7245db 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java
@@ -329,13 +329,29 @@ public class ConnectHandler extends HandlerWrapper
*/
protected SocketChannel connect(HttpServletRequest request, String host, int port) throws IOException
{
- _logger.debug("Establishing connection to {}:{}", host, port);
- // Connect to remote server
SocketChannel channel = SocketChannel.open();
- channel.socket().setTcpNoDelay(true);
- channel.socket().connect(new InetSocketAddress(host, port), getConnectTimeout());
- _logger.debug("Established connection to {}:{}", host, port);
- return channel;
+ try
+ {
+ // Connect to remote server
+ _logger.debug("Establishing connection to {}:{}", host, port);
+ channel.socket().setTcpNoDelay(true);
+ channel.socket().connect(new InetSocketAddress(host, port), getConnectTimeout());
+ _logger.debug("Established connection to {}:{}", host, port);
+ return channel;
+ }
+ catch (IOException x)
+ {
+ _logger.debug("Failed to establish connection to " + host + ":" + port, x);
+ try
+ {
+ channel.close();
+ }
+ catch (IOException xx)
+ {
+ Log.ignore(xx);
+ }
+ throw x;
+ }
}
protected void prepareContext(HttpServletRequest request, ConcurrentMap<String, Object> context)

Back to the top