On 30 April 2011 12:11, <[email protected]> wrote: > Author: olegk > Date: Sat Apr 30 11:11:51 2011 > New Revision: 1098098 > > URL: http://svn.apache.org/viewvc?rev=1098098&view=rev > Log: > Re-introduced timeout parameter for connection manager operations
[snip]. Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/params/ClientPNames.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/params/ClientPNames.java?rev=1098098&r1=1098097&r2=1098098&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/params/ClientPNames.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/params/ClientPNames.java Sat Apr 30 11:11:51 2011 @@ -126,5 +126,16 @@ public interface ClientPNames { */ public static final String DEFAULT_HOST = "http.default-host"; + /** + * Defines the timeout in milliseconds used when retrieving an instance of + * {@link org.apache.http.conn.ManagedClientConnection} from the + * {@link org.apache.http.conn.ClientConnectionManager}. + * <p> + * This parameter expects a value of type {@link Long}. Why is this Long? The related parameter CoreConnectionPNames.CONNECTION_TIMEOUT is an Integer. + * <p> + * @since 4.2 + */ + public static final String CONN_MANAGER_TIMEOUT = "http.conn-manager.timeout"; + } [snip] > Modified: > httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/params/HttpClientParams.java > URL: > http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/params/HttpClientParams.java?rev=1098098&r1=1098097&r2=1098098&view=diff > ============================================================================== > --- > httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/params/HttpClientParams.java > (original) > +++ > httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/params/HttpClientParams.java > Sat Apr 30 11:11:51 2011 > @@ -28,6 +28,7 @@ package org.apache.http.client.params; > > import org.apache.http.annotation.Immutable; > > +import org.apache.http.params.HttpConnectionParams; > import org.apache.http.params.HttpParams; > > /** > @@ -93,4 +94,28 @@ public class HttpClientParams { > params.setParameter(ClientPNames.COOKIE_POLICY, cookiePolicy); > } > > + /** > + * @since 4.2 > + */ > + public static void setConnectionManagerTimeout(final HttpParams params, > long timeout) { > + if (params == null) { > + throw new IllegalArgumentException("HTTP parameters may not be > null"); > + } > + params.setLongParameter(ClientPNames.CONN_MANAGER_TIMEOUT, timeout); > + } > + > + /** > + * @since 4.2 > + */ > + public static long getConnectionManagerTimeout(final HttpParams params) { > + if (params == null) { > + throw new IllegalArgumentException("HTTP parameters may not be > null"); > + } > + Long timeout = (Long) > params.getParameter(ClientPNames.CONN_MANAGER_TIMEOUT); > + if (timeout != null) { > + return timeout.longValue(); > + } > + return HttpConnectionParams.getConnectionTimeout(params); > + } Not sure I understand why the ConnMgr Timeout should default to the Connection Timeout. [Also one is long, the other int.] If the ConnMgr timeout is not set, I would expect it to default to 0 (i.e. infinite) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
