Fixed bug #289221: HttpExchange does not timeout when using blocking connector.
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@901 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
991b97ff9e
commit
432ab6605a
|
@ -29,7 +29,8 @@ jetty-7.0.0.RC6-SNAPSHOT
|
|||
+ 289146 formalize reload policy functionality
|
||||
+ 289156 jetty-client: no longer throw runtime exception for bad authn details
|
||||
+ 288182 PUT request fails during retry
|
||||
+ JETTY-719: Document state machine of jetty http client
|
||||
+ JETTY-719 Document state machine of jetty http client
|
||||
+ 289221 HttpExchange does not timeout when using blocking connector
|
||||
|
||||
jetty-6.1.20 27 August 2009
|
||||
+ JETTY-838 Don't log and throw
|
||||
|
|
|
@ -93,7 +93,6 @@ public class HttpClient extends HttpBuffers implements Attributes
|
|||
Connector _connector;
|
||||
private long _idleTimeout = 20000;
|
||||
private long _timeout = 320000;
|
||||
int _soTimeout = 10000;
|
||||
private Timeout _timeoutQ = new Timeout();
|
||||
private Address _proxy;
|
||||
private Authorization _proxyAuthentication;
|
||||
|
@ -626,16 +625,24 @@ 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.
|
||||
*/
|
||||
@Deprecated
|
||||
public int getSoTimeout()
|
||||
{
|
||||
return _soTimeout;
|
||||
return Long.valueOf(getTimeout()).intValue();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void setSoTimeout(int so)
|
||||
/**
|
||||
* @deprecated use {@link #setTimeout(long)} instead.
|
||||
* @param timeout the period in ms that an exchange will wait for a response from the server.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setSoTimeout(int timeout)
|
||||
{
|
||||
_soTimeout = so;
|
||||
setTimeout(timeout);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -649,11 +656,11 @@ public class HttpClient extends HttpBuffers implements Attributes
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param ms the period in ms that an exchange will wait for a response from the server.
|
||||
* @param timeout the period in ms that an exchange will wait for a response from the server.
|
||||
*/
|
||||
public void setTimeout(long ms)
|
||||
public void setTimeout(long timeout)
|
||||
{
|
||||
_timeout = ms;
|
||||
_timeout = timeout;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -119,8 +119,8 @@ public class HttpConnection implements Connection
|
|||
{
|
||||
SelectChannelEndPoint scep = (SelectChannelEndPoint)_endp;
|
||||
scep.scheduleWrite();
|
||||
_destination.getHttpClient().schedule(_timeout);
|
||||
}
|
||||
_destination.getHttpClient().schedule(_timeout);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -16,12 +16,10 @@ package org.eclipse.jetty.client;
|
|||
import java.io.IOException;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSession;
|
||||
|
||||
import org.eclipse.jetty.http.HttpBuffers;
|
||||
import org.eclipse.jetty.http.HttpMethods;
|
||||
import org.eclipse.jetty.http.HttpVersions;
|
||||
import org.eclipse.jetty.http.ssl.SslSelectChannelEndPoint;
|
||||
|
@ -134,7 +132,6 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
|||
Address address = destination.isProxied() ? destination.getProxy() : destination.getAddress();
|
||||
channel.configureBlocking( false );
|
||||
channel.connect(address.toSocketAddress());
|
||||
channel.socket().setSoTimeout( _httpClient._soTimeout );
|
||||
_selectorManager.register( channel, destination );
|
||||
}
|
||||
|
||||
|
|
|
@ -300,6 +300,27 @@ public abstract class AbstractHttpExchangeCancelTest extends TestCase
|
|||
assertFalse(exchange.isAssociated());
|
||||
}
|
||||
|
||||
public void testHttpExchangeOnExpire() throws Exception
|
||||
{
|
||||
HttpClient httpClient = getHttpClient();
|
||||
httpClient.stop();
|
||||
httpClient.setTimeout(2000);
|
||||
httpClient.start();
|
||||
|
||||
TestHttpExchange exchange = new TestHttpExchange();
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/?action=wait5000");
|
||||
|
||||
httpClient.send(exchange);
|
||||
|
||||
int status = exchange.waitForDone();
|
||||
assertEquals(HttpExchange.STATUS_EXPIRED, status);
|
||||
assertFalse(exchange.isResponseCompleted());
|
||||
assertFalse(exchange.isFailed());
|
||||
assertTrue(exchange.isExpired());
|
||||
assertFalse(exchange.isAssociated());
|
||||
}
|
||||
|
||||
protected abstract HttpClient getHttpClient();
|
||||
|
||||
protected Address newAddress()
|
||||
|
|
|
@ -41,25 +41,4 @@ public class BlockingHttpExchangeCancelTest extends AbstractHttpExchangeCancelTe
|
|||
{
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
public void DONTtestHttpExchangeOnExpire() throws Exception
|
||||
{
|
||||
HttpClient httpClient = getHttpClient();
|
||||
httpClient.stop();
|
||||
httpClient.setSoTimeout(2000);
|
||||
httpClient.start();
|
||||
|
||||
TestHttpExchange exchange = new TestHttpExchange();
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/?action=wait5000");
|
||||
|
||||
httpClient.send(exchange);
|
||||
|
||||
int status = exchange.waitForDone();
|
||||
assertEquals(HttpExchange.STATUS_EXPIRED, status);
|
||||
assertFalse(exchange.isResponseCompleted());
|
||||
assertFalse(exchange.isFailed());
|
||||
assertTrue(exchange.isExpired());
|
||||
assertFalse(exchange.isAssociated());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,25 +41,4 @@ public class NonBlockingHttpExchangeCancelTest extends AbstractHttpExchangeCance
|
|||
{
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
public void testHttpExchangeOnExpire() throws Exception
|
||||
{
|
||||
HttpClient httpClient = getHttpClient();
|
||||
httpClient.stop();
|
||||
httpClient.setTimeout(2000);
|
||||
httpClient.start();
|
||||
|
||||
TestHttpExchange exchange = new TestHttpExchange();
|
||||
exchange.setAddress(newAddress());
|
||||
exchange.setURI("/?action=wait5000");
|
||||
|
||||
httpClient.send(exchange);
|
||||
|
||||
int status = exchange.waitForDone();
|
||||
assertEquals(HttpExchange.STATUS_EXPIRED, status);
|
||||
assertFalse(exchange.isResponseCompleted());
|
||||
assertFalse(exchange.isFailed());
|
||||
assertTrue(exchange.isExpired());
|
||||
assertFalse(exchange.isAssociated());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue