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
This commit is contained in:
parent
f7a0d7d134
commit
215bf562aa
|
@ -329,14 +329,30 @@ 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();
|
||||
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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue