[java-support] 02/04: JSPT-78 - HttpClientBuilder should support duration syntax
Ian Young
ian at iay.org.uk
Fri Jan 26 13:14:54 EST 2018
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch master
in repository java-support.
View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=3dda3f1fe9c66b55a658de955e401f94ba29599f
commit 3dda3f1fe9c66b55a658de955e401f94ba29599f
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jan 17 14:48:44 2018 -0500
JSPT-78 - HttpClientBuilder should support duration syntax
https://issues.shibboleth.net/jira/browse/JSPT-78
---
.../java/support/httpclient/HttpClientBuilder.java | 36 ++++++++++++++--------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuilder.java b/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuilder.java
index f46f6cb..500e742 100644
--- a/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuilder.java
+++ b/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpClientBuilder.java
@@ -43,6 +43,7 @@ import org.apache.http.util.CharsetUtils;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
+import net.shibboleth.utilities.java.support.annotation.Duration;
import net.shibboleth.utilities.java.support.collection.IterableSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
@@ -148,7 +149,7 @@ public class HttpClientBuilder {
/**
* Maximum period inactivity between two consecutive data packets in milliseconds. Default value: 60000 (60 seconds)
*/
- private int socketTimeout;
+ @Duration private int socketTimeout;
/** Socket buffer size in bytes. Default size is 8192 bytes. */
private int socketBufferSize;
@@ -157,13 +158,13 @@ public class HttpClientBuilder {
* Maximum length of time in milliseconds to wait for the connection to be established. Default value: 60000 (60
* seconds)
*/
- private int connectionTimeout;
+ @Duration private int connectionTimeout;
/**
* Maximum length of time in milliseconds to wait for a connection to be returned from the connection
* manager. Default value: 60000 (60 seconds);
*/
- private int connectionRequestTimeout;
+ @Duration private int connectionRequestTimeout;
/**
* Max total simultaneous connections allowed by the pooling connection manager.
@@ -361,7 +362,7 @@ public class HttpClientBuilder {
*
* @return maximum period inactivity between two consecutive data packets in milliseconds
*/
- public int getSocketTimeout() {
+ @Duration public int getSocketTimeout() {
return socketTimeout;
}
@@ -371,8 +372,11 @@ public class HttpClientBuilder {
*
* @param timeout maximum period inactivity between two consecutive data packets in milliseconds
*/
- public void setSocketTimeout(final int timeout) {
- this.socketTimeout = timeout;
+ public void setSocketTimeout(@Duration final long timeout) {
+ if (timeout > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("Timeout was too large");
+ }
+ this.socketTimeout = (int) timeout;
}
/**
@@ -399,7 +403,7 @@ public class HttpClientBuilder {
*
* @return maximum length of time in milliseconds to wait for the connection to be established
*/
- public int getConnectionTimeout() {
+ @Duration public int getConnectionTimeout() {
return connectionTimeout;
}
@@ -409,17 +413,20 @@ public class HttpClientBuilder {
*
* @param timeout maximum length of time in milliseconds to wait for the connection to be established
*/
- public void setConnectionTimeout(final int timeout) {
- connectionTimeout = timeout;
+ public void setConnectionTimeout(@Duration final long timeout) {
+ if (timeout > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("Timeout was too large");
+ }
+ connectionTimeout = (int) timeout;
}
-
+
/**
* Gets the maximum length of time in milliseconds to wait for a connection to be returned from the connection
* manager. A value of less than 1 indicates no timeout.
*
* @return maximum length of time in milliseconds to wait for the connection to be established
*/
- public int getConnectionRequestTimeout() {
+ @Duration public int getConnectionRequestTimeout() {
return connectionRequestTimeout;
}
@@ -429,8 +436,11 @@ public class HttpClientBuilder {
*
* @param timeout maximum length of time in milliseconds to wait for the connection to be established
*/
- public void setConnectionRequestTimeout(final int timeout) {
- connectionRequestTimeout = timeout;
+ public void setConnectionRequestTimeout(@Duration final long timeout) {
+ if (timeout > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("Timeout was too large");
+ }
+ connectionRequestTimeout = (int) timeout;
}
/**
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list