diff options
author | David Daney <ddaney@avtrex.com> | 2006-12-08 20:45:43 +0000 |
---|---|---|
committer | David Daney <ddaney@avtrex.com> | 2006-12-08 20:45:43 +0000 |
commit | 8ac4d056ac03bee426cfe4ae705ef7a440716458 (patch) | |
tree | f923a21c412eb04e63506b9fcebb8a0d5faeb431 /java/net | |
parent | 6959321995f4485ec98cb99635eb94394641a4b4 (diff) | |
download | classpath-8ac4d056ac03bee426cfe4ae705ef7a440716458.tar.gz |
* gnu/java/net/protocol/http/HTTPConnection.java (imports): Add
SocketException.
(HTTPConnection): Handle NumberFormatException in properties parsing.
(Pool.get): Set timeout on reused sockets.
* gnu/java/net/protocol/http/HTTPURLConnection.java (proxyPort):
Initialize.
(HTTPURLConnection): Cleanup properties handling.
(getConnection): Use both connection and read timeouts.
(setConnectTimeout): Removed.
(setReadTimeout): New method.
* java/net/URLConnection.java (timeout): Renamed to...
(connectTimeout): ... connectTimeout throughout.
(readTimeout): New field.
(getReadTimeout): New method.
(setReadTimeout): New method.
Diffstat (limited to 'java/net')
-rw-r--r-- | java/net/URLConnection.java | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/java/net/URLConnection.java b/java/net/URLConnection.java index 28142b10a..468838db7 100644 --- a/java/net/URLConnection.java +++ b/java/net/URLConnection.java @@ -174,9 +174,14 @@ public abstract class URLConnection private static boolean dateformats_initialized; /** - * The timeout period. + * The connection timeout period. */ - private int timeout; + private int connectTimeout; + + /** + * The read timeout period. + */ + private int readTimeout; /* Cached ParsePosition, used when parsing dates. */ private ParsePosition position; @@ -216,8 +221,8 @@ public abstract class URLConnection } /** - * Returns the connection timeout speed, in milliseconds, or zero if the timeout - * is infinite or not set. + * Returns the connection timeout speed, in milliseconds, or zero if + * the timeout is infinite or not set. * * @return The timeout. * @@ -225,7 +230,7 @@ public abstract class URLConnection */ public int getConnectTimeout() { - return timeout; + return connectTimeout; } /** @@ -235,7 +240,7 @@ public abstract class URLConnection * * Throws an <code>IllegalArgumentException</code> if timeout < 0. * - * @param timeout - The timeout, in milliseconds. + * @param timeout the timeout, in milliseconds. * * @since 1.5 */ @@ -244,7 +249,45 @@ public abstract class URLConnection { if( timeout < 0 ) throw new IllegalArgumentException("Timeout must be 0 or positive."); - this.timeout = timeout; + connectTimeout = timeout; + } + + /** + * Returns the read timeout, in milliseconds, or zero if the timeout + * is infinite or not set. + * + * @return The timeout. + * + * @see #setReadTimeout + * + * @since 1.5 + */ + public int getReadTimeout() + { + return readTimeout; + } + + /** + * Set the read timeout, in milliseconds, or zero if the timeout + * is to be considered infinite. Note that in certain socket + * implementations/platforms this method may not have any effect. + * + * Throws an <code>IllegalArgumentException</code> if timeout < 0. + * + * @param timeout - The timeout, in milliseconds. + * + * @throws IllegalArgumentException if timeout is negative. + * + * @see #getReadTimeout + * + * @since 1.5 + */ + public void setReadTimeout(int timeout) + throws IllegalArgumentException + { + if( timeout < 0 ) + throw new IllegalArgumentException("Timeout must be 0 or positive."); + readTimeout = timeout; } /** |