diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java index 0fcb5dc36dc..688af0e76cd 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java @@ -246,6 +246,7 @@ public class HttpClient extends HttpBuffers implements Attributes _timeoutQ.schedule(task); } + /* ------------------------------------------------------------ */ public void schedule(Timeout.Task task, long timeout) { _timeoutQ.schedule(task, timeout - _timeoutQ.getDuration()); @@ -529,6 +530,7 @@ public class HttpClient extends HttpBuffers implements Attributes public void startConnection(HttpDestination destination) throws IOException; } + /* ------------------------------------------------------------ */ /** * if a keystore location has been provided then client will attempt to use it as the keystore, * otherwise we simply ignore certificates and run with a loose ssl context. @@ -567,6 +569,7 @@ public class HttpClient extends HttpBuffers implements Attributes _idleTimeout = ms; } + /* ------------------------------------------------------------ */ /** * @return the period in ms that an exchange will wait for a response from the server. * @deprecated use {@link #getTimeout()} instead. @@ -577,6 +580,7 @@ public class HttpClient extends HttpBuffers implements Attributes return Long.valueOf(getTimeout()).intValue(); } + /* ------------------------------------------------------------ */ /** * @deprecated use {@link #setTimeout(long)} instead. * @param timeout the period in ms that an exchange will wait for a response from the server. @@ -605,6 +609,7 @@ public class HttpClient extends HttpBuffers implements Attributes _timeout = timeout; } + /* ------------------------------------------------------------ */ /** * @return the period in ms before timing out an attempt to connect */ @@ -613,6 +618,7 @@ public class HttpClient extends HttpBuffers implements Attributes return _connectTimeout; } + /* ------------------------------------------------------------ */ /** * @param connectTimeout the period in ms before timing out an attempt to connect */ diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java index 9570a4b1506..f2c8e108242 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java @@ -44,7 +44,6 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector, { private final HttpClient _httpClient; private final Manager _selectorManager=new Manager(); - private final Timeout _connectTimer = new Timeout(); private final Map _connectingChannels = new ConcurrentHashMap(); private SSLContext _sslContext; private Buffers _sslBuffers; @@ -62,31 +61,6 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector, protected void doStart() throws Exception { super.doStart(); - _connectTimer.setDuration(_httpClient.getConnectTimeout()); - _connectTimer.setNow(); - - if (!_httpClient.isConnectBlocking()) - { - _httpClient._threadPool.dispatch(new Runnable() - { - public void run() - { - while (isRunning()) - { - _connectTimer.tick(System.currentTimeMillis()); - try - { - Thread.sleep(200); - } - catch (InterruptedException x) - { - Thread.currentThread().interrupt(); - break; - } - } - } - }); - } _selectorManager.start(); @@ -136,7 +110,6 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector, @Override protected void doStop() throws Exception { - _connectTimer.cancelAll(); _selectorManager.stop(); } @@ -156,7 +129,7 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector, channel.connect(address.toSocketAddress()); _selectorManager.register( channel, destination ); ConnectTimeout connectTimeout = new ConnectTimeout(channel, destination); - _connectTimer.schedule(connectTimeout); + _httpClient.schedule(connectTimeout,_httpClient.getConnectTimeout()); _connectingChannels.put(channel, connectTimeout); } else