diff --git a/httpclient/src/main/java/org/apache/http/client/CircularRedirectException.java b/httpclient/src/main/java/org/apache/http/client/CircularRedirectException.java index e2b0517ee..63384b624 100644 --- a/httpclient/src/main/java/org/apache/http/client/CircularRedirectException.java +++ b/httpclient/src/main/java/org/apache/http/client/CircularRedirectException.java @@ -30,12 +30,15 @@ package org.apache.http.client; +import net.jcip.annotations.Immutable; + /** * Signals a circular redirect * * * @since 4.0 */ +@Immutable public class CircularRedirectException extends RedirectException { private static final long serialVersionUID = 6830063487001091803L; diff --git a/httpclient/src/main/java/org/apache/http/client/ClientProtocolException.java b/httpclient/src/main/java/org/apache/http/client/ClientProtocolException.java index dc7df99ab..2ea7bddd1 100644 --- a/httpclient/src/main/java/org/apache/http/client/ClientProtocolException.java +++ b/httpclient/src/main/java/org/apache/http/client/ClientProtocolException.java @@ -32,11 +32,14 @@ package org.apache.http.client; import java.io.IOException; +import net.jcip.annotations.Immutable; + /** * Signals an error in the HTTP protocol. * * @since 4.0 */ +@Immutable public class ClientProtocolException extends IOException { private static final long serialVersionUID = -5596590843227115865L; diff --git a/httpclient/src/main/java/org/apache/http/client/HttpResponseException.java b/httpclient/src/main/java/org/apache/http/client/HttpResponseException.java index 497408b58..a81711051 100644 --- a/httpclient/src/main/java/org/apache/http/client/HttpResponseException.java +++ b/httpclient/src/main/java/org/apache/http/client/HttpResponseException.java @@ -30,11 +30,14 @@ package org.apache.http.client; +import net.jcip.annotations.Immutable; + /** * Signals a non 2xx HTTP response. * * @since 4.0 */ +@Immutable public class HttpResponseException extends ClientProtocolException { private static final long serialVersionUID = -7186627969477257933L; diff --git a/httpclient/src/main/java/org/apache/http/client/NonRepeatableRequestException.java b/httpclient/src/main/java/org/apache/http/client/NonRepeatableRequestException.java index c3685bded..a840315d6 100644 --- a/httpclient/src/main/java/org/apache/http/client/NonRepeatableRequestException.java +++ b/httpclient/src/main/java/org/apache/http/client/NonRepeatableRequestException.java @@ -30,6 +30,8 @@ package org.apache.http.client; +import net.jcip.annotations.Immutable; + import org.apache.http.ProtocolException; /** @@ -39,6 +41,7 @@ import org.apache.http.ProtocolException; * * @since 4.0 */ +@Immutable public class NonRepeatableRequestException extends ProtocolException { private static final long serialVersionUID = 82685265288806048L; diff --git a/httpclient/src/main/java/org/apache/http/client/RedirectException.java b/httpclient/src/main/java/org/apache/http/client/RedirectException.java index 8720b115d..109f9144a 100644 --- a/httpclient/src/main/java/org/apache/http/client/RedirectException.java +++ b/httpclient/src/main/java/org/apache/http/client/RedirectException.java @@ -30,6 +30,8 @@ package org.apache.http.client; +import net.jcip.annotations.Immutable; + import org.apache.http.ProtocolException; /** @@ -38,6 +40,7 @@ import org.apache.http.ProtocolException; * * @since 4.0 */ +@Immutable public class RedirectException extends ProtocolException { private static final long serialVersionUID = 4418824536372559326L; diff --git a/httpclient/src/main/java/org/apache/http/client/params/AuthPolicy.java b/httpclient/src/main/java/org/apache/http/client/params/AuthPolicy.java index 05f446b3d..7dbfff9cf 100644 --- a/httpclient/src/main/java/org/apache/http/client/params/AuthPolicy.java +++ b/httpclient/src/main/java/org/apache/http/client/params/AuthPolicy.java @@ -31,10 +31,13 @@ package org.apache.http.client.params; +import net.jcip.annotations.Immutable; + /** * * @since 4.0 */ +@Immutable public final class AuthPolicy { private AuthPolicy() { diff --git a/httpclient/src/main/java/org/apache/http/client/params/CookiePolicy.java b/httpclient/src/main/java/org/apache/http/client/params/CookiePolicy.java index 3ed6e06bc..cc969fe0b 100644 --- a/httpclient/src/main/java/org/apache/http/client/params/CookiePolicy.java +++ b/httpclient/src/main/java/org/apache/http/client/params/CookiePolicy.java @@ -31,10 +31,13 @@ package org.apache.http.client.params; +import net.jcip.annotations.Immutable; + /** * * @since 4.0 */ +@Immutable public final class CookiePolicy { /** diff --git a/httpclient/src/main/java/org/apache/http/client/params/HttpClientParams.java b/httpclient/src/main/java/org/apache/http/client/params/HttpClientParams.java index 4f7182801..fc91c3337 100644 --- a/httpclient/src/main/java/org/apache/http/client/params/HttpClientParams.java +++ b/httpclient/src/main/java/org/apache/http/client/params/HttpClientParams.java @@ -30,6 +30,8 @@ package org.apache.http.client.params; +import net.jcip.annotations.Immutable; + import org.apache.http.params.HttpParams; /** @@ -40,6 +42,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@Immutable public class HttpClientParams { private HttpClientParams() { diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java index ea3096c3a..6b1df0c74 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java @@ -37,6 +37,8 @@ import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; +import net.jcip.annotations.Immutable; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.Header; @@ -67,6 +69,7 @@ import org.apache.http.protocol.ExecutionContext; * * @since 4.0 */ +@Immutable public class RequestAddCookies implements HttpRequestInterceptor { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java index 372c46bae..83a501709 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java @@ -34,6 +34,8 @@ package org.apache.http.client.protocol; import java.io.IOException; import java.util.Collection; +import net.jcip.annotations.Immutable; + import org.apache.http.Header; import org.apache.http.HttpException; import org.apache.http.HttpRequest; @@ -49,6 +51,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ +@Immutable public class RequestDefaultHeaders implements HttpRequestInterceptor { public RequestDefaultHeaders() { diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/RequestProxyAuthentication.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestProxyAuthentication.java index d87d90e0a..756d856e3 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestProxyAuthentication.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestProxyAuthentication.java @@ -33,6 +33,8 @@ package org.apache.http.client.protocol; import java.io.IOException; +import net.jcip.annotations.Immutable; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpException; @@ -51,6 +53,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ +@Immutable public class RequestProxyAuthentication implements HttpRequestInterceptor { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/RequestTargetAuthentication.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestTargetAuthentication.java index 860f32a8a..d28e023bd 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestTargetAuthentication.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestTargetAuthentication.java @@ -33,6 +33,8 @@ package org.apache.http.client.protocol; import java.io.IOException; +import net.jcip.annotations.Immutable; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpException; @@ -51,6 +53,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ +@Immutable public class RequestTargetAuthentication implements HttpRequestInterceptor { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java b/httpclient/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java index 2dec5117b..d69d08a87 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java @@ -34,6 +34,8 @@ package org.apache.http.client.protocol; import java.io.IOException; import java.util.List; +import net.jcip.annotations.Immutable; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.Header; @@ -58,6 +60,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ +@Immutable public class ResponseProcessCookies implements HttpResponseInterceptor { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java index cddceff46..b83b0656c 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java @@ -32,12 +32,14 @@ package org.apache.http.client.utils; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import net.jcip.annotations.Immutable; /** * A collection of utilities to workaround limitations of Java clone framework. * * @since 4.0 */ +@Immutable public class CloneUtils { public static Object clone(final Object obj) throws CloneNotSupportedException { diff --git a/httpclient/src/main/java/org/apache/http/client/utils/JdkIdn.java b/httpclient/src/main/java/org/apache/http/client/utils/JdkIdn.java index 862f3c5c4..1ea20f5eb 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/JdkIdn.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/JdkIdn.java @@ -33,13 +33,16 @@ package org.apache.http.client.utils; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import net.jcip.annotations.Immutable; + /** * Uses the java.net.IDN class through reflection. * * @since 4.0 */ +@Immutable public class JdkIdn implements Idn { - private Method toUnicode; + private final Method toUnicode; /** * diff --git a/httpclient/src/main/java/org/apache/http/client/utils/Rfc3492Idn.java b/httpclient/src/main/java/org/apache/http/client/utils/Rfc3492Idn.java index f86f17bc5..e541edabd 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/Rfc3492Idn.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/Rfc3492Idn.java @@ -32,11 +32,14 @@ package org.apache.http.client.utils; import java.util.StringTokenizer; +import net.jcip.annotations.Immutable; + /** * Implementation from pseudo code in RFC 3492. * * @since 4.0 */ +@Immutable public class Rfc3492Idn implements Idn { private static final int base = 36; private static final int tmin = 1; diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java index 2f8517057..22d2e2b25 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java @@ -33,6 +33,8 @@ package org.apache.http.client.utils; import java.net.URI; import java.net.URISyntaxException; +import net.jcip.annotations.Immutable; + import org.apache.http.HttpHost; /** @@ -41,6 +43,7 @@ import org.apache.http.HttpHost; * * @since 4.0 */ +@Immutable public class URIUtils { /** diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java index e304465f2..e0c6fa8fa 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java @@ -39,6 +39,9 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; + +import net.jcip.annotations.Immutable; + import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.NameValuePair; @@ -51,6 +54,7 @@ import org.apache.http.util.EntityUtils; * * @since 4.0 */ +@Immutable public class URLEncodedUtils { public static final String CONTENT_TYPE = "application/x-www-form-urlencoded"; diff --git a/httpclient/src/main/java/org/apache/http/conn/ConnectTimeoutException.java b/httpclient/src/main/java/org/apache/http/conn/ConnectTimeoutException.java index d751a679b..5f39af8fd 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ConnectTimeoutException.java +++ b/httpclient/src/main/java/org/apache/http/conn/ConnectTimeoutException.java @@ -33,6 +33,8 @@ package org.apache.http.conn; import java.io.InterruptedIOException; +import net.jcip.annotations.Immutable; + /** * A timeout while connecting to an HTTP server or waiting for an * available connection from an HttpConnectionManager. @@ -40,6 +42,7 @@ import java.io.InterruptedIOException; * * @since 4.0 */ +@Immutable public class ConnectTimeoutException extends InterruptedIOException { private static final long serialVersionUID = -4816682903149535989L; diff --git a/httpclient/src/main/java/org/apache/http/conn/ConnectionPoolTimeoutException.java b/httpclient/src/main/java/org/apache/http/conn/ConnectionPoolTimeoutException.java index b8148b8b0..025efd747 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ConnectionPoolTimeoutException.java +++ b/httpclient/src/main/java/org/apache/http/conn/ConnectionPoolTimeoutException.java @@ -31,6 +31,8 @@ package org.apache.http.conn; +import net.jcip.annotations.Immutable; + /** * A timeout while waiting for an available connection * from a connection manager. @@ -38,6 +40,7 @@ package org.apache.http.conn; * * @since 4.0 */ +@Immutable public class ConnectionPoolTimeoutException extends ConnectTimeoutException { private static final long serialVersionUID = -7898874842020245128L; diff --git a/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java b/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java index ce6533ad5..a2272cec5 100644 --- a/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java +++ b/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java @@ -32,6 +32,8 @@ package org.apache.http.conn; import java.net.ConnectException; +import net.jcip.annotations.Immutable; + import org.apache.http.HttpHost; /** @@ -40,6 +42,7 @@ import org.apache.http.HttpHost; * * @since 4.0 */ +@Immutable public class HttpHostConnectException extends ConnectException { private static final long serialVersionUID = -3194482710275220224L; diff --git a/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java index 0d0e85f47..3250debe3 100644 --- a/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java +++ b/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java @@ -41,6 +41,8 @@ import java.util.Collections; import java.util.List; import java.util.Arrays; +import net.jcip.annotations.Immutable; + import org.apache.http.conn.scheme.SocketFactory; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; @@ -54,6 +56,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@Immutable public final class MultihomePlainSocketFactory implements SocketFactory { /** diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java b/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java index c823924c8..8e1f9157c 100644 --- a/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java +++ b/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java @@ -33,6 +33,8 @@ package org.apache.http.conn.routing; import java.net.InetAddress; +import net.jcip.annotations.Immutable; + import org.apache.http.HttpHost; /** @@ -47,6 +49,7 @@ import org.apache.http.HttpHost; * * @since 4.0 */ +@Immutable public final class HttpRoute implements RouteInfo, Cloneable { private static final HttpHost[] EMPTY_HTTP_HOST_ARRAY = new HttpHost[]{}; diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java index 5b5bd006c..a3c29a935 100644 --- a/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java +++ b/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java @@ -37,6 +37,8 @@ import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketTimeoutException; +import net.jcip.annotations.Immutable; + import org.apache.http.conn.ConnectTimeoutException; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; @@ -47,6 +49,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@Immutable public final class PlainSocketFactory implements SocketFactory { /** diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java b/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java index 803a4812f..bca4b19e7 100644 --- a/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java +++ b/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java @@ -32,6 +32,8 @@ package org.apache.http.conn.scheme; import java.util.Locale; +import net.jcip.annotations.Immutable; + import org.apache.http.util.LangUtils; /** @@ -52,6 +54,7 @@ import org.apache.http.util.LangUtils; * * @since 4.0 */ +@Immutable public final class Scheme { /** The name of this scheme, in lowercase. (e.g. http, https) */ @@ -69,6 +72,11 @@ public final class Scheme { /** A string representation, for {@link #toString toString}. */ private String stringRep; + /* + * This is used to cache the result of the toString() method + * Since the method always generates the same value, there's no + * need to synchronize. + */ /** diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeRegistry.java b/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeRegistry.java index c0d45995e..00ca32d06 100644 --- a/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeRegistry.java +++ b/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeRegistry.java @@ -35,6 +35,9 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import net.jcip.annotations.GuardedBy; +import net.jcip.annotations.ThreadSafe; + import org.apache.http.HttpHost; /** @@ -48,9 +51,11 @@ import org.apache.http.HttpHost; * * @since 4.0 */ +@ThreadSafe public final class SchemeRegistry { /** The available schemes in this registry. */ + @GuardedBy("this") private final Map registeredSchemes; diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java b/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java index 0f18cfe8b..64fb9e582 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java +++ b/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java @@ -31,6 +31,8 @@ package org.apache.http.conn.ssl; +import net.jcip.annotations.Immutable; + import org.apache.http.conn.util.InetAddressUtils; import java.io.IOException; @@ -59,6 +61,7 @@ import javax.net.ssl.SSLSocket; * * @since 4.0 */ +@Immutable public abstract class AbstractVerifier implements X509HostnameVerifier { /** diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java b/httpclient/src/main/java/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java index de41c3caf..8d7d06478 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java +++ b/httpclient/src/main/java/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java @@ -31,6 +31,8 @@ package org.apache.http.conn.ssl; +import net.jcip.annotations.Immutable; + /** * The ALLOW_ALL HostnameVerifier essentially turns hostname verification * off. This implementation is a no-op, and never throws the SSLException. @@ -38,6 +40,7 @@ package org.apache.http.conn.ssl; * * @since 4.0 */ +@Immutable public class AllowAllHostnameVerifier extends AbstractVerifier { public final void verify( diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier.java b/httpclient/src/main/java/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier.java index 75fcaf9d1..71036c479 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier.java +++ b/httpclient/src/main/java/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier.java @@ -33,6 +33,8 @@ package org.apache.http.conn.ssl; import javax.net.ssl.SSLException; +import net.jcip.annotations.Immutable; + /** * The HostnameVerifier that works the same way as Curl and Firefox. *

@@ -46,6 +48,7 @@ import javax.net.ssl.SSLException; * * @since 4.0 */ +@Immutable public class BrowserCompatHostnameVerifier extends AbstractVerifier { public final void verify( diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/StrictHostnameVerifier.java b/httpclient/src/main/java/org/apache/http/conn/ssl/StrictHostnameVerifier.java index b1deb6a5d..95975ba74 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ssl/StrictHostnameVerifier.java +++ b/httpclient/src/main/java/org/apache/http/conn/ssl/StrictHostnameVerifier.java @@ -33,6 +33,8 @@ package org.apache.http.conn.ssl; import javax.net.ssl.SSLException; +import net.jcip.annotations.Immutable; + /** * The Strict HostnameVerifier works the same way as Sun Java 1.4, Sun * Java 5, Sun Java 6-rc. It's also pretty close to IE6. This @@ -53,6 +55,7 @@ import javax.net.ssl.SSLException; * * @since 4.0 */ +@Immutable public class StrictHostnameVerifier extends AbstractVerifier { public final void verify( diff --git a/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java b/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java index ddf64b557..66c536aee 100644 --- a/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java +++ b/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java @@ -33,11 +33,14 @@ package org.apache.http.conn.util; import java.util.regex.Pattern; +import net.jcip.annotations.Immutable; + /** * A collection of utilities relating to InetAddresses. * * @since 4.0 */ +@Immutable public class InetAddressUtils { private InetAddressUtils() { diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java b/httpclient/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java index 0fa5de3fc..8a0bdf9a1 100644 --- a/httpclient/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java +++ b/httpclient/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java @@ -34,6 +34,8 @@ package org.apache.http.cookie; import java.io.Serializable; import java.util.Comparator; +import net.jcip.annotations.Immutable; + /** * This cookie comparator can be used to compare identity of cookies. * @@ -45,6 +47,7 @@ import java.util.Comparator; * * @since 4.0 */ +@Immutable public class CookieIdentityComparator implements Serializable, Comparator { private static final long serialVersionUID = 4466565437490631532L; diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java b/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java index 9010d4ab5..1176ba631 100644 --- a/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java +++ b/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java @@ -32,6 +32,8 @@ package org.apache.http.cookie; import java.util.Locale; +import net.jcip.annotations.Immutable; + /** * CookieOrigin class incapsulates details of an origin server that * are relevant when parsing, validating or matching HTTP cookies. @@ -39,6 +41,7 @@ import java.util.Locale; * * @since 4.0 */ +@Immutable public final class CookieOrigin { private final String host; diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookiePathComparator.java b/httpclient/src/main/java/org/apache/http/cookie/CookiePathComparator.java index 571fc7d4d..c290e0fc3 100644 --- a/httpclient/src/main/java/org/apache/http/cookie/CookiePathComparator.java +++ b/httpclient/src/main/java/org/apache/http/cookie/CookiePathComparator.java @@ -34,6 +34,8 @@ package org.apache.http.cookie; import java.io.Serializable; import java.util.Comparator; +import net.jcip.annotations.Immutable; + /** * This cookie comparator ensures that multiple cookies satisfying * a common criteria are ordered in the Cookie header such @@ -49,6 +51,7 @@ import java.util.Comparator; * * @since 4.0 */ +@Immutable public class CookiePathComparator implements Serializable, Comparator { private static final long serialVersionUID = 7523645369616405818L; diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java b/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java index 463cc0a7d..edf4ac275 100644 --- a/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java +++ b/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java @@ -37,6 +37,9 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import net.jcip.annotations.GuardedBy; +import net.jcip.annotations.ThreadSafe; + import org.apache.http.params.HttpParams; /** @@ -47,8 +50,10 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@ThreadSafe public final class CookieSpecRegistry { + @GuardedBy("this") private final Map registeredSpecs; public CookieSpecRegistry() { diff --git a/httpclient/src/main/java/org/apache/http/cookie/MalformedCookieException.java b/httpclient/src/main/java/org/apache/http/cookie/MalformedCookieException.java index ee5bc5150..efe563b2e 100644 --- a/httpclient/src/main/java/org/apache/http/cookie/MalformedCookieException.java +++ b/httpclient/src/main/java/org/apache/http/cookie/MalformedCookieException.java @@ -31,6 +31,8 @@ package org.apache.http.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.ProtocolException; /** @@ -40,6 +42,7 @@ import org.apache.http.ProtocolException; * * @since 4.0 */ +@Immutable public class MalformedCookieException extends ProtocolException { private static final long serialVersionUID = -6695462944287282185L; diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/BasicSchemeFactory.java b/httpclient/src/main/java/org/apache/http/impl/auth/BasicSchemeFactory.java index 29c3903ea..874f9b322 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/BasicSchemeFactory.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/BasicSchemeFactory.java @@ -31,6 +31,8 @@ package org.apache.http.impl.auth; +import net.jcip.annotations.Immutable; + import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthSchemeFactory; import org.apache.http.params.HttpParams; @@ -40,6 +42,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@Immutable public class BasicSchemeFactory implements AuthSchemeFactory { public AuthScheme newInstance(final HttpParams params) { diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/DigestSchemeFactory.java b/httpclient/src/main/java/org/apache/http/impl/auth/DigestSchemeFactory.java index 20d513467..8f1a82484 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/DigestSchemeFactory.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/DigestSchemeFactory.java @@ -31,6 +31,8 @@ package org.apache.http.impl.auth; +import net.jcip.annotations.Immutable; + import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthSchemeFactory; import org.apache.http.params.HttpParams; @@ -40,6 +42,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@Immutable public class DigestSchemeFactory implements AuthSchemeFactory { public AuthScheme newInstance(final HttpParams params) { diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineException.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineException.java index cb13a2ada..bd064aa43 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineException.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineException.java @@ -30,6 +30,8 @@ package org.apache.http.impl.auth; +import net.jcip.annotations.Immutable; + import org.apache.http.auth.AuthenticationException; /** @@ -38,6 +40,7 @@ import org.apache.http.auth.AuthenticationException; * * @since 4.0 */ +@Immutable public class NTLMEngineException extends AuthenticationException { private static final long serialVersionUID = 6027981323731768824L; diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java b/httpclient/src/main/java/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java index 252ffff43..4b2d09ce8 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java @@ -30,6 +30,8 @@ package org.apache.http.impl.auth; +import net.jcip.annotations.Immutable; + /** * Authentication credentials required to respond to a authentication * challenge are invalid @@ -37,6 +39,7 @@ package org.apache.http.impl.auth; * * @since 4.0 */ +@Immutable public class UnsupportedDigestAlgorithmException extends RuntimeException { private static final long serialVersionUID = 319558534317118022L; diff --git a/httpclient/src/main/java/org/apache/http/impl/client/BasicCookieStore.java b/httpclient/src/main/java/org/apache/http/impl/client/BasicCookieStore.java index 7d49f624b..7555db5ec 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/BasicCookieStore.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/BasicCookieStore.java @@ -37,6 +37,9 @@ import java.util.Date; import java.util.Iterator; import java.util.List; +import net.jcip.annotations.GuardedBy; +import net.jcip.annotations.ThreadSafe; + import org.apache.http.client.CookieStore; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieIdentityComparator; @@ -47,10 +50,13 @@ import org.apache.http.cookie.CookieIdentityComparator; * * @since 4.0 */ +@ThreadSafe public class BasicCookieStore implements CookieStore { + @GuardedBy("this") private final ArrayList cookies; + @GuardedBy("this") private final Comparator cookieComparator; // -------------------------------------------------------- Class Variables diff --git a/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java b/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java index 5844f4c1f..a562e713b 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java @@ -32,6 +32,9 @@ package org.apache.http.impl.client; import java.util.HashMap; +import net.jcip.annotations.GuardedBy; +import net.jcip.annotations.ThreadSafe; + import org.apache.http.auth.AuthScope; import org.apache.http.auth.Credentials; import org.apache.http.client.CredentialsProvider; @@ -42,8 +45,10 @@ import org.apache.http.client.CredentialsProvider; * * @since 4.0 */ +@ThreadSafe public class BasicCredentialsProvider implements CredentialsProvider { + @GuardedBy("this") private final HashMap credMap; /** diff --git a/httpclient/src/main/java/org/apache/http/impl/client/BasicResponseHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/BasicResponseHandler.java index 27dbd04e2..0ad60c237 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/BasicResponseHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/BasicResponseHandler.java @@ -33,6 +33,8 @@ package org.apache.http.impl.client; import java.io.IOException; +import net.jcip.annotations.Immutable; + import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.StatusLine; @@ -55,6 +57,7 @@ import org.apache.http.util.EntityUtils; * * @since 4.0 */ +@Immutable public class BasicResponseHandler implements ResponseHandler { /** diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java index 30f416561..d4406eace 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java @@ -30,6 +30,8 @@ */ package org.apache.http.impl.client; +import net.jcip.annotations.Immutable; + import org.apache.http.HeaderElement; import org.apache.http.HeaderElementIterator; import org.apache.http.HttpResponse; @@ -50,6 +52,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ +@Immutable public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveStrategy { public long getKeepAliveDuration(HttpResponse response, HttpContext context) { diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java index 599722e98..8ab2f8f4f 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java @@ -38,6 +38,8 @@ import java.net.UnknownHostException; import javax.net.ssl.SSLHandshakeException; +import net.jcip.annotations.Immutable; + import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpRequest; import org.apache.http.NoHttpResponseException; @@ -51,6 +53,7 @@ import org.apache.http.protocol.ExecutionContext; * * @since 4.0 */ +@Immutable public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler { /** the number of times a method will be retried */ diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java index c2168eebf..9b6efb346 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java @@ -34,6 +34,8 @@ package org.apache.http.impl.client; import java.net.URI; import java.net.URISyntaxException; +import net.jcip.annotations.Immutable; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.Header; @@ -61,6 +63,7 @@ import org.apache.http.protocol.ExecutionContext; * * @since 4.0 */ +@Immutable public class DefaultRedirectHandler implements RedirectHandler { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java index 1cd525317..4d52a927e 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java @@ -34,6 +34,8 @@ import java.security.Principal; import javax.net.ssl.SSLSession; +import net.jcip.annotations.Immutable; + import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthState; import org.apache.http.auth.Credentials; @@ -47,6 +49,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ +@Immutable public class DefaultUserTokenHandler implements UserTokenHandler { public Object getUserToken(final HttpContext context) { diff --git a/httpclient/src/main/java/org/apache/http/impl/client/TunnelRefusedException.java b/httpclient/src/main/java/org/apache/http/impl/client/TunnelRefusedException.java index bf7381a10..ce18581dc 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/TunnelRefusedException.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/TunnelRefusedException.java @@ -31,6 +31,8 @@ package org.apache.http.impl.client; +import net.jcip.annotations.Immutable; + import org.apache.http.HttpException; import org.apache.http.HttpResponse; @@ -38,6 +40,7 @@ import org.apache.http.HttpResponse; * * @since 4.0 */ +@Immutable public class TunnelRefusedException extends HttpException { private static final long serialVersionUID = -8646722842745617323L; diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java b/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java index 6f3d68f2a..d7f9d5856 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java @@ -33,6 +33,9 @@ package org.apache.http.impl.conn; import java.io.IOException; import java.io.InputStream; import java.io.ByteArrayInputStream; + +import net.jcip.annotations.Immutable; + import org.apache.commons.logging.Log; /** @@ -41,6 +44,7 @@ import org.apache.commons.logging.Log; * * @since 4.0 */ +@Immutable public class Wire { private final Log log; diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieAttributeHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieAttributeHandler.java index 175055d97..e7c01ffcd 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieAttributeHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieAttributeHandler.java @@ -30,6 +30,8 @@ */ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieAttributeHandler; import org.apache.http.cookie.CookieOrigin; @@ -39,6 +41,7 @@ import org.apache.http.cookie.MalformedCookieException; * * @since 4.0 */ +@Immutable public abstract class AbstractCookieAttributeHandler implements CookieAttributeHandler { public void validate(final Cookie cookie, final CookieOrigin origin) diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java index a413d35f1..272d01998 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java @@ -30,6 +30,8 @@ */ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.MalformedCookieException; import org.apache.http.cookie.SetCookie; @@ -37,6 +39,7 @@ import org.apache.http.cookie.SetCookie; * * @since 4.0 */ +@Immutable public class BasicCommentHandler extends AbstractCookieAttributeHandler { public BasicCommentHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java index eef72bb49..46ada0280 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java @@ -30,6 +30,8 @@ */ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieAttributeHandler; import org.apache.http.cookie.CookieOrigin; @@ -40,6 +42,7 @@ import org.apache.http.cookie.SetCookie; * * @since 4.0 */ +@Immutable public class BasicDomainHandler implements CookieAttributeHandler { public BasicDomainHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java index e282c4c13..c3c66dd74 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java @@ -30,6 +30,8 @@ */ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.MalformedCookieException; import org.apache.http.cookie.SetCookie; @@ -38,6 +40,7 @@ import org.apache.http.cookie.SetCookie; * * @since 4.0 */ +@Immutable public class BasicExpiresHandler extends AbstractCookieAttributeHandler { /** Valid date patterns */ diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java index 861c2d5ab..e2a833a2e 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java @@ -32,6 +32,8 @@ package org.apache.http.impl.cookie; import java.util.Date; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.MalformedCookieException; import org.apache.http.cookie.SetCookie; @@ -39,6 +41,7 @@ import org.apache.http.cookie.SetCookie; * * @since 4.0 */ +@Immutable public class BasicMaxAgeHandler extends AbstractCookieAttributeHandler { public BasicMaxAgeHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java index e867d9e5c..2bf2282ae 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java @@ -30,6 +30,8 @@ */ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieAttributeHandler; import org.apache.http.cookie.CookieOrigin; @@ -40,6 +42,7 @@ import org.apache.http.cookie.SetCookie; * * @since 4.0 */ +@Immutable public class BasicPathHandler implements CookieAttributeHandler { public BasicPathHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java index 429938035..8ee94b7f5 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java @@ -30,6 +30,8 @@ */ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieOrigin; import org.apache.http.cookie.MalformedCookieException; @@ -39,6 +41,7 @@ import org.apache.http.cookie.SetCookie; * * @since 4.0 */ +@Immutable public class BasicSecureHandler extends AbstractCookieAttributeHandler { public BasicSecureHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpecFactory.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpecFactory.java index d074c52a5..3ba6c246b 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpecFactory.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpecFactory.java @@ -31,6 +31,8 @@ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecFactory; import org.apache.http.cookie.params.CookieSpecPNames; @@ -41,6 +43,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@Immutable public class BestMatchSpecFactory implements CookieSpecFactory { public CookieSpec newInstance(final HttpParams params) { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java index b66e1dcf1..00d5b8819 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java @@ -31,6 +31,8 @@ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecFactory; import org.apache.http.cookie.params.CookieSpecPNames; @@ -41,6 +43,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@Immutable public class BrowserCompatSpecFactory implements CookieSpecFactory { public CookieSpec newInstance(final HttpParams params) { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/DateParseException.java b/httpclient/src/main/java/org/apache/http/impl/cookie/DateParseException.java index a018cb7fc..3c9d24227 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/DateParseException.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/DateParseException.java @@ -31,6 +31,7 @@ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; /** * An exception to indicate an error parsing a date string. @@ -40,6 +41,7 @@ package org.apache.http.impl.cookie; * * @since 4.0 */ +@Immutable public class DateParseException extends Exception { private static final long serialVersionUID = 4417696455000643370L; diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java index 753991339..3a6e30b50 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java @@ -33,6 +33,8 @@ package org.apache.http.impl.cookie; import java.util.Locale; import java.util.StringTokenizer; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieOrigin; import org.apache.http.cookie.MalformedCookieException; @@ -41,6 +43,7 @@ import org.apache.http.cookie.MalformedCookieException; * * @since 4.0 */ +@Immutable public class NetscapeDomainHandler extends BasicDomainHandler { public NetscapeDomainHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftHeaderParser.java b/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftHeaderParser.java index 9310e5f46..c10b92cbc 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftHeaderParser.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftHeaderParser.java @@ -34,6 +34,8 @@ package org.apache.http.impl.cookie; import java.util.ArrayList; import java.util.List; +import net.jcip.annotations.Immutable; + import org.apache.http.HeaderElement; import org.apache.http.NameValuePair; import org.apache.http.ParseException; @@ -46,6 +48,7 @@ import org.apache.http.util.CharArrayBuffer; * * @since 4.0 */ +@Immutable public class NetscapeDraftHeaderParser { public final static NetscapeDraftHeaderParser DEFAULT = new NetscapeDraftHeaderParser(); diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java index 4bf617c29..bc5355b7d 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java @@ -34,6 +34,8 @@ package org.apache.http.impl.cookie; import java.util.ArrayList; import java.util.List; +import net.jcip.annotations.Immutable; + import org.apache.http.FormattedHeader; import org.apache.http.Header; import org.apache.http.HeaderElement; @@ -52,6 +54,7 @@ import org.apache.http.util.CharArrayBuffer; * * @since 4.0 */ +@Immutable public class NetscapeDraftSpec extends CookieSpecBase { protected static final String EXPIRES_PATTERN = "EEE, dd-MMM-yyyy HH:mm:ss z"; diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java b/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java index ba2147b52..5df9ecec1 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java @@ -31,6 +31,8 @@ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecFactory; import org.apache.http.cookie.params.CookieSpecPNames; @@ -41,6 +43,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@Immutable public class NetscapeDraftSpecFactory implements CookieSpecFactory { public CookieSpec newInstance(final HttpParams params) { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java index 0f258b336..6bb19605c 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java @@ -37,15 +37,18 @@ import java.io.Reader; import java.util.ArrayList; import java.util.Collection; +import net.jcip.annotations.Immutable; + /** * Parses the list from publicsuffix.org * and configures a PublicSuffixFilter. * * @since 4.0 */ +@Immutable public class PublicSuffixListParser { private static final int MAX_LINE_LEN = 256; - private PublicSuffixFilter filter; + private final PublicSuffixFilter filter; PublicSuffixListParser(PublicSuffixFilter filter) { this.filter = filter; diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java index 443aa99ce..7ffb2821e 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java @@ -32,6 +32,8 @@ package org.apache.http.impl.cookie; import java.util.Locale; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieAttributeHandler; import org.apache.http.cookie.CookieOrigin; @@ -42,6 +44,7 @@ import org.apache.http.cookie.SetCookie; * * @since 4.0 */ +@Immutable public class RFC2109DomainHandler implements CookieAttributeHandler { public RFC2109DomainHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecFactory.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecFactory.java index da168f095..cd4d88aae 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecFactory.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecFactory.java @@ -31,6 +31,8 @@ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecFactory; import org.apache.http.cookie.params.CookieSpecPNames; @@ -41,6 +43,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@Immutable public class RFC2109SpecFactory implements CookieSpecFactory { public CookieSpec newInstance(final HttpParams params) { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java index 10069a074..50471a7b0 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java @@ -30,6 +30,8 @@ */ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieOrigin; import org.apache.http.cookie.MalformedCookieException; @@ -39,6 +41,7 @@ import org.apache.http.cookie.SetCookie; * * @since 4.0 */ +@Immutable public class RFC2109VersionHandler extends AbstractCookieAttributeHandler { public RFC2109VersionHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965CommentUrlAttributeHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965CommentUrlAttributeHandler.java index 808eeae62..aa7a15bf2 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965CommentUrlAttributeHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965CommentUrlAttributeHandler.java @@ -31,6 +31,8 @@ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieAttributeHandler; import org.apache.http.cookie.CookieOrigin; @@ -43,7 +45,8 @@ import org.apache.http.cookie.SetCookie2; * * @since 4.0 */ - public class RFC2965CommentUrlAttributeHandler implements CookieAttributeHandler { +@Immutable +public class RFC2965CommentUrlAttributeHandler implements CookieAttributeHandler { public RFC2965CommentUrlAttributeHandler() { super(); diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DiscardAttributeHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DiscardAttributeHandler.java index 730a04dbc..5dc0b6721 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DiscardAttributeHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DiscardAttributeHandler.java @@ -31,6 +31,8 @@ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieAttributeHandler; import org.apache.http.cookie.CookieOrigin; @@ -43,7 +45,8 @@ import org.apache.http.cookie.SetCookie2; * * @since 4.0 */ - public class RFC2965DiscardAttributeHandler implements CookieAttributeHandler { +@Immutable +public class RFC2965DiscardAttributeHandler implements CookieAttributeHandler { public RFC2965DiscardAttributeHandler() { super(); diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java index 91d31a5fc..cb992508b 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java @@ -33,6 +33,8 @@ package org.apache.http.impl.cookie; import java.util.Locale; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieAttributeHandler; @@ -46,6 +48,7 @@ import org.apache.http.cookie.SetCookie; * * @since 3.1 */ +@Immutable public class RFC2965DomainAttributeHandler implements CookieAttributeHandler { public RFC2965DomainAttributeHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java index b4816ff43..b7575aaf8 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java @@ -33,6 +33,8 @@ package org.apache.http.impl.cookie; import java.util.StringTokenizer; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieAttributeHandler; @@ -46,6 +48,7 @@ import org.apache.http.cookie.SetCookie2; * * @since 4.0 */ +@Immutable public class RFC2965PortAttributeHandler implements CookieAttributeHandler { public RFC2965PortAttributeHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecFactory.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecFactory.java index 1916d2854..bd16986a5 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecFactory.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecFactory.java @@ -31,6 +31,8 @@ package org.apache.http.impl.cookie; +import net.jcip.annotations.Immutable; + import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecFactory; import org.apache.http.cookie.params.CookieSpecPNames; @@ -41,6 +43,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 */ +@Immutable public class RFC2965SpecFactory implements CookieSpecFactory { public CookieSpec newInstance(final HttpParams params) {