[java-openws COMMIT] in /branches/REL_1/src/main/java/org/opensaml: util/resource/HttpResource.java ws/soap/client/ht...
noreply at shibboleth.net
noreply at shibboleth.net
Tue Feb 24 18:30:04 EST 2015
Author: putmanb
Date: Tue Feb 24 18:30:04 2015
New Revision: 474
URL: http://svn.shibboleth.net/view/java-openws?rev=474&view=rev
Log:
SIDP-624:
- Set internal connection and socket timeouts on HttpResource to 90 sec.
- Set internal socket timeout on HttpClientBuilder to 90 sec.
Modified:
branches/REL_1/src/main/java/org/opensaml/util/resource/HttpResource.java
branches/REL_1/src/main/java/org/opensaml/ws/soap/client/http/HttpClientBuilder.java
Modified: branches/REL_1/src/main/java/org/opensaml/util/resource/HttpResource.java
URL: http://svn.shibboleth.net/view/java-openws/branches/REL_1/src/main/java/org/opensaml/util/resource/HttpResource.java?rev=474&r1=473&r2=474&view=diff
==============================================================================
--- branches/REL_1/src/main/java/org/opensaml/util/resource/HttpResource.java (original)
+++ branches/REL_1/src/main/java/org/opensaml/util/resource/HttpResource.java Tue Feb 24 18:30:04 2015
@@ -26,6 +26,7 @@
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.HeadMethod;
+import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.httpclient.util.DateParseException;
import org.apache.commons.httpclient.util.DateUtil;
import org.joda.time.DateTime;
@@ -36,6 +37,12 @@
* A resource representing a file retrieved from a URL using Apache Commons HTTPClient.
*/
public class HttpResource extends AbstractFilteredResource {
+
+ /** HttpClient connection timeout in milliseconds. */
+ private static final int CONNECTION_TIMEOUT = 90*1000;
+
+ /** HttpClient socket timeout in milliseconds. */
+ private static final int SOCKET_TIMEOUT = 90*1000;
/** HTTP URL of the resource. */
private String resourceUrl;
@@ -57,6 +64,10 @@
}
httpClient = new HttpClient();
+
+ HttpConnectionManagerParams connMgrParams = httpClient.getHttpConnectionManager().getParams();
+ connMgrParams.setConnectionTimeout(CONNECTION_TIMEOUT);
+ connMgrParams.setSoTimeout(SOCKET_TIMEOUT);
}
/**
@@ -76,6 +87,10 @@
}
httpClient = new HttpClient();
+
+ HttpConnectionManagerParams connMgrParams = httpClient.getHttpConnectionManager().getParams();
+ connMgrParams.setConnectionTimeout(CONNECTION_TIMEOUT);
+ connMgrParams.setSoTimeout(SOCKET_TIMEOUT);
}
/** {@inheritDoc} */
Modified: branches/REL_1/src/main/java/org/opensaml/ws/soap/client/http/HttpClientBuilder.java
URL: http://svn.shibboleth.net/view/java-openws/branches/REL_1/src/main/java/org/opensaml/ws/soap/client/http/HttpClientBuilder.java?rev=474&r1=473&r2=474&view=diff
==============================================================================
--- branches/REL_1/src/main/java/org/opensaml/ws/soap/client/http/HttpClientBuilder.java (original)
+++ branches/REL_1/src/main/java/org/opensaml/ws/soap/client/http/HttpClientBuilder.java Tue Feb 24 18:30:04 2015
@@ -79,6 +79,9 @@
/** Number of times a failed connection to a host should be retried. */
private int connectionRetryAttempts;
+
+ /** Amount of time, in milliseconds, to wait for data to be read from a socket, defaults to 90000. */
+ private int socketTimeout;
/** Socket factory used for the 'https' scheme. */
private SecureProtocolSocketFactory httpsProtocolSocketFactory;
@@ -100,6 +103,7 @@
maxConnectionsPerHost = 5;
maxTotalConnectons = 20;
connectionRetryAttempts = 0;
+ socketTimeout = 90*1000;
}
/**
@@ -126,6 +130,8 @@
connMgrParams.setReceiveBufferSize(getReceiveBufferSize());
connMgrParams.setSendBufferSize(getSendBufferSize());
connMgrParams.setTcpNoDelay(isTcpNoDelay());
+ // Note: this is deliberately an internal default for now.
+ connMgrParams.setSoTimeout(socketTimeout);
MultiThreadedHttpConnectionManager connMgr = new MultiThreadedHttpConnectionManager();
connMgr.setParams(connMgrParams);
More information about the commits
mailing list