diff --git a/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalEntityEnclosingHttpRequest.java b/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalEntityEnclosingHttpRequest.java index 6e0b4d64a..a7972b8bf 100644 --- a/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalEntityEnclosingHttpRequest.java +++ b/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalEntityEnclosingHttpRequest.java @@ -32,10 +32,8 @@ import java.net.URI; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.protocol.HTTP; -@NotThreadSafe class InternalEntityEnclosingHttpRequest extends InternalHttpRequest implements HttpEntityEnclosingRequest { private HttpEntity entity; diff --git a/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java b/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java index 8d4595424..0dccb31ab 100644 --- a/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java +++ b/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java @@ -34,7 +34,6 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.http.HttpVersion; import org.apache.http.ProtocolVersion; import org.apache.http.RequestLine; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.Configurable; import org.apache.http.client.methods.HttpExecutionAware; @@ -44,7 +43,6 @@ import org.apache.http.message.AbstractHttpMessage; import org.apache.http.message.BasicRequestLine; import org.apache.http.util.Args; -@NotThreadSafe class InternalHttpRequest extends AbstractHttpMessage implements HttpUriRequest, HttpExecutionAware, Configurable { diff --git a/httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cache/CachingHttpClient.java b/httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cache/CachingHttpClient.java index a54ff1966..0443ce61c 100644 --- a/httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cache/CachingHttpClient.java +++ b/httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cache/CachingHttpClient.java @@ -57,7 +57,8 @@ import org.apache.http.HttpVersion; import org.apache.http.ProtocolException; import org.apache.http.ProtocolVersion; import org.apache.http.RequestLine; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.ResponseHandler; @@ -126,7 +127,7 @@ import org.apache.http.util.VersionInfo; * @deprecated (4.3) use {@link CachingHttpClientBuilder} or {@link CachingHttpClients}. */ @Deprecated -@ThreadSafe // So long as the responseCache implementation is threadsafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) public class CachingHttpClient implements HttpClient { /** diff --git a/httpclient-cache/src/main/java/org/apache/http/client/cache/HeaderConstants.java b/httpclient-cache/src/main/java/org/apache/http/client/cache/HeaderConstants.java index 0a25f24b7..37213826e 100644 --- a/httpclient-cache/src/main/java/org/apache/http/client/cache/HeaderConstants.java +++ b/httpclient-cache/src/main/java/org/apache/http/client/cache/HeaderConstants.java @@ -26,13 +26,10 @@ */ package org.apache.http.client.cache; -import org.apache.http.annotation.Immutable; - /** * Records static constants for various HTTP header names. * @since 4.1 */ -@Immutable public class HeaderConstants { public static final String GET_METHOD = "GET"; diff --git a/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCacheContext.java b/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCacheContext.java index 6c8af1dd6..f1a0d1928 100644 --- a/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCacheContext.java +++ b/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCacheContext.java @@ -26,7 +26,6 @@ */ package org.apache.http.client.cache; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.HttpContext; @@ -34,7 +33,6 @@ import org.apache.http.protocol.HttpContext; /** * @since 4.3 */ -@NotThreadSafe public class HttpCacheContext extends HttpClientContext { /** diff --git a/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCacheEntry.java b/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCacheEntry.java index d8bf81b51..c537a48e0 100644 --- a/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCacheEntry.java +++ b/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCacheEntry.java @@ -36,7 +36,8 @@ import org.apache.http.Header; import org.apache.http.HeaderIterator; import org.apache.http.ProtocolVersion; import org.apache.http.StatusLine; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.utils.DateUtils; import org.apache.http.message.HeaderGroup; import org.apache.http.protocol.HTTP; @@ -51,7 +52,7 @@ import org.apache.http.util.Args; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class HttpCacheEntry implements Serializable { private static final long serialVersionUID = -6300496422359477413L; diff --git a/httpclient-cache/src/main/java/org/apache/http/client/cache/InputLimit.java b/httpclient-cache/src/main/java/org/apache/http/client/cache/InputLimit.java index dd96eebc3..4d2ff4379 100644 --- a/httpclient-cache/src/main/java/org/apache/http/client/cache/InputLimit.java +++ b/httpclient-cache/src/main/java/org/apache/http/client/cache/InputLimit.java @@ -26,15 +26,12 @@ */ package org.apache.http.client.cache; -import org.apache.http.annotation.NotThreadSafe; - /** * Used to limiting the size of an incoming response body of * unknown size that is optimistically being read in anticipation * of caching it. * @since 4.1 */ -@NotThreadSafe // reached public class InputLimit { private final long value; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCacheStorage.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCacheStorage.java index 76a525c42..56d8a2085 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCacheStorage.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCacheStorage.java @@ -28,7 +28,8 @@ package org.apache.http.impl.client.cache; import java.io.IOException; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HttpCacheEntry; import org.apache.http.client.cache.HttpCacheStorage; import org.apache.http.client.cache.HttpCacheUpdateCallback; @@ -43,7 +44,7 @@ import org.apache.http.client.cache.HttpCacheUpdateCallback; * * @since 4.1 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class BasicHttpCacheStorage implements HttpCacheStorage { private final CacheMap entries; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicIdGenerator.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicIdGenerator.java index 04236abdc..5cdf45b89 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicIdGenerator.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicIdGenerator.java @@ -33,19 +33,17 @@ import java.security.SecureRandom; import java.util.Formatter; import java.util.Locale; -import org.apache.http.annotation.GuardedBy; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * Should produce reasonably unique tokens. */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) class BasicIdGenerator { private final String hostname; private final SecureRandom rnd; - - @GuardedBy("this") private long count; public BasicIdGenerator() { diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntity.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntity.java index 66e4af749..529d6983a 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntity.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntity.java @@ -33,12 +33,13 @@ import java.io.Serializable; import org.apache.http.Header; import org.apache.http.HttpEntity; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HttpCacheEntry; import org.apache.http.protocol.HTTP; import org.apache.http.util.Args; -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) class CacheEntity implements HttpEntity, Serializable { private static final long serialVersionUID = -3467082284120936233L; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntryUpdater.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntryUpdater.java index 4801b9dcb..aa4c83cf4 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntryUpdater.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntryUpdater.java @@ -36,7 +36,8 @@ import java.util.ListIterator; import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HeaderConstants; import org.apache.http.client.cache.HttpCacheEntry; import org.apache.http.client.cache.Resource; @@ -52,7 +53,7 @@ import org.apache.http.util.Args; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) class CacheEntryUpdater { private final ResourceFactory resourceFactory; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java index 57c2d913b..84cc5ef0d 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java @@ -37,7 +37,8 @@ import org.apache.http.Header; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HeaderConstants; import org.apache.http.client.cache.HttpCacheEntry; import org.apache.http.client.cache.HttpCacheInvalidator; @@ -51,7 +52,7 @@ import org.apache.http.protocol.HTTP; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) class CacheInvalidator implements HttpCacheInvalidator { private final HttpCacheStorage storage; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java index 3d006d5fb..91ca500eb 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java @@ -40,7 +40,8 @@ import org.apache.http.Header; import org.apache.http.HeaderElement; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HeaderConstants; import org.apache.http.client.cache.HttpCacheEntry; import org.apache.http.client.utils.URIUtils; @@ -48,7 +49,7 @@ import org.apache.http.client.utils.URIUtils; /** * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) class CacheKeyGenerator { private static final URI BASE_URI = URI.create("http://example.com/"); diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheValidityPolicy.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheValidityPolicy.java index 7690e8aff..2231fc6c7 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheValidityPolicy.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheValidityPolicy.java @@ -31,7 +31,8 @@ import java.util.Date; import org.apache.http.Header; import org.apache.http.HeaderElement; import org.apache.http.HttpRequest; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HeaderConstants; import org.apache.http.client.cache.HttpCacheEntry; import org.apache.http.client.utils.DateUtils; @@ -40,7 +41,7 @@ import org.apache.http.protocol.HTTP; /** * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) class CacheValidityPolicy { public static final long MAX_AGE = 2147483648L; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheableRequestPolicy.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheableRequestPolicy.java index d7877034e..356bd2ec8 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheableRequestPolicy.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheableRequestPolicy.java @@ -33,7 +33,8 @@ import org.apache.http.HeaderElement; import org.apache.http.HttpRequest; import org.apache.http.HttpVersion; import org.apache.http.ProtocolVersion; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HeaderConstants; /** @@ -41,7 +42,7 @@ import org.apache.http.client.cache.HeaderConstants; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) class CacheableRequestPolicy { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedHttpResponseGenerator.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedHttpResponseGenerator.java index f74a2e42c..42c01e9af 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedHttpResponseGenerator.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedHttpResponseGenerator.java @@ -33,7 +33,8 @@ import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.HttpVersion; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HeaderConstants; import org.apache.http.client.cache.HttpCacheEntry; import org.apache.http.client.methods.CloseableHttpResponse; @@ -48,7 +49,7 @@ import org.apache.http.protocol.HTTP; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) class CachedHttpResponseGenerator { private final CacheValidityPolicy validityStrategy; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedResponseSuitabilityChecker.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedResponseSuitabilityChecker.java index e7c940c6e..8f5397157 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedResponseSuitabilityChecker.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedResponseSuitabilityChecker.java @@ -35,7 +35,8 @@ import org.apache.http.HeaderElement; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpStatus; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HeaderConstants; import org.apache.http.client.cache.HttpCacheEntry; import org.apache.http.client.utils.DateUtils; @@ -46,7 +47,7 @@ import org.apache.http.client.utils.DateUtils; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) class CachedResponseSuitabilityChecker { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java index d9c63dd9a..67f574852 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java @@ -49,7 +49,8 @@ import org.apache.http.HttpVersion; import org.apache.http.ProtocolException; import org.apache.http.ProtocolVersion; import org.apache.http.RequestLine; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.CacheResponseStatus; import org.apache.http.client.cache.HeaderConstants; import org.apache.http.client.cache.HttpCacheContext; @@ -99,7 +100,7 @@ import org.apache.http.util.VersionInfo; * * @since 4.3 */ -@ThreadSafe // So long as the responseCache implementation is threadsafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) public class CachingExec implements ClientExecChain { private final static boolean SUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS = false; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClients.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClients.java index 35beb6dde..36c034bc3 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClients.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClients.java @@ -29,7 +29,6 @@ package org.apache.http.impl.client.cache; import java.io.File; -import org.apache.http.annotation.Immutable; import org.apache.http.impl.client.CloseableHttpClient; /** @@ -38,7 +37,6 @@ import org.apache.http.impl.client.CloseableHttpClient; * * @since 4.3 */ -@Immutable public class CachingHttpClients { private CachingHttpClients() { diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CombinedEntity.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CombinedEntity.java index a4cd65ce3..c665339a1 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CombinedEntity.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CombinedEntity.java @@ -32,12 +32,10 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.SequenceInputStream; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.client.cache.Resource; import org.apache.http.entity.AbstractHttpEntity; import org.apache.http.util.Args; -@NotThreadSafe class CombinedEntity extends AbstractHttpEntity { private final Resource resource; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ConditionalRequestBuilder.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ConditionalRequestBuilder.java index 0f4bd0962..9caa048e0 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ConditionalRequestBuilder.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ConditionalRequestBuilder.java @@ -31,7 +31,8 @@ import java.util.Map; import org.apache.http.Header; import org.apache.http.HeaderElement; import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HeaderConstants; import org.apache.http.client.cache.HttpCacheEntry; import org.apache.http.client.methods.HttpRequestWrapper; @@ -39,7 +40,7 @@ import org.apache.http.client.methods.HttpRequestWrapper; /** * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) class ConditionalRequestBuilder { /** diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultFailureCache.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultFailureCache.java index c0626faa0..8000b9ce6 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultFailureCache.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultFailureCache.java @@ -26,19 +26,20 @@ */ package org.apache.http.impl.client.cache; -import org.apache.http.annotation.ThreadSafe; - import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; + /** * Implements a bounded failure cache. The oldest entries are discarded when * the maximum size is exceeded. * * @since 4.3 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class DefaultFailureCache implements FailureCache { static final int DEFAULT_MAX_SIZE = 1000; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultHttpCacheEntrySerializer.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultHttpCacheEntrySerializer.java index f84501bcb..9572b784b 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultHttpCacheEntrySerializer.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultHttpCacheEntrySerializer.java @@ -32,7 +32,8 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HttpCacheEntry; import org.apache.http.client.cache.HttpCacheEntrySerializationException; import org.apache.http.client.cache.HttpCacheEntrySerializer; @@ -45,7 +46,7 @@ import org.apache.http.client.cache.HttpCacheEntrySerializer; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class DefaultHttpCacheEntrySerializer implements HttpCacheEntrySerializer { @Override diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ExponentialBackOffSchedulingStrategy.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ExponentialBackOffSchedulingStrategy.java index 21b644ff8..66aa5325a 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ExponentialBackOffSchedulingStrategy.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ExponentialBackOffSchedulingStrategy.java @@ -26,13 +26,14 @@ */ package org.apache.http.impl.client.cache; -import org.apache.http.annotation.ThreadSafe; -import org.apache.http.util.Args; - import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; +import org.apache.http.util.Args; + /** * An implementation that backs off exponentially based on the number of * consecutive failed attempts stored in the @@ -56,7 +57,7 @@ import java.util.concurrent.TimeUnit; * * @since 4.3 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class ExponentialBackOffSchedulingStrategy implements SchedulingStrategy { public static final long DEFAULT_BACK_OFF_RATE = 10; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FailureCacheValue.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FailureCacheValue.java index 98137aea1..c76e183b0 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FailureCacheValue.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FailureCacheValue.java @@ -26,14 +26,15 @@ */ package org.apache.http.impl.client.cache; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * The error count with a creation timestamp and its associated key. * * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class FailureCacheValue { private final long creationTimeInNanos; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResource.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResource.java index eef9c9ab9..ecf6ffce0 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResource.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResource.java @@ -31,7 +31,8 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.Resource; /** @@ -39,7 +40,7 @@ import org.apache.http.client.cache.Resource; * * @since 4.1 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class FileResource implements Resource { private static final long serialVersionUID = 4132244415919043397L; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResourceFactory.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResourceFactory.java index f2c717c54..b530eab1a 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResourceFactory.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResourceFactory.java @@ -31,7 +31,8 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.InputLimit; import org.apache.http.client.cache.Resource; import org.apache.http.client.cache.ResourceFactory; @@ -41,7 +42,7 @@ import org.apache.http.client.cache.ResourceFactory; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class FileResourceFactory implements ResourceFactory { private final File cacheDir; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResource.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResource.java index edf6b0f2f..f46bd099a 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResource.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResource.java @@ -29,7 +29,8 @@ package org.apache.http.impl.client.cache; import java.io.ByteArrayInputStream; import java.io.InputStream; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.Resource; /** @@ -37,7 +38,7 @@ import org.apache.http.client.cache.Resource; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class HeapResource implements Resource { private static final long serialVersionUID = -2078599905620463394L; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java index 87a1b2a1d..11506e24e 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java @@ -30,7 +30,8 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.InputLimit; import org.apache.http.client.cache.Resource; import org.apache.http.client.cache.ResourceFactory; @@ -40,7 +41,7 @@ import org.apache.http.client.cache.ResourceFactory; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class HeapResourceFactory implements ResourceFactory { @Override diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java index b255d0f47..229bce681 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java @@ -35,9 +35,7 @@ import java.io.RandomAccessFile; import java.nio.channels.FileChannel; import org.apache.http.HttpEntity; -import org.apache.http.annotation.Immutable; -@Immutable class IOUtils { static void consume(final HttpEntity entity) throws IOException { diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ImmediateSchedulingStrategy.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ImmediateSchedulingStrategy.java index 263c6b31a..cb8c27eca 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ImmediateSchedulingStrategy.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ImmediateSchedulingStrategy.java @@ -26,21 +26,22 @@ */ package org.apache.http.impl.client.cache; -import org.apache.http.annotation.ThreadSafe; -import org.apache.http.util.Args; - import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; +import org.apache.http.util.Args; + /** * Immediately schedules any incoming validation request. Relies on * {@link CacheConfig} to configure the used {@link java.util.concurrent.ThreadPoolExecutor}. * * @since 4.3 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class ImmediateSchedulingStrategy implements SchedulingStrategy { private final ExecutorService executor; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java index 0a02658de..cf65771da 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java @@ -33,7 +33,8 @@ import java.util.HashSet; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HttpCacheEntry; import org.apache.http.client.cache.HttpCacheStorage; import org.apache.http.client.cache.HttpCacheUpdateCallback; @@ -70,7 +71,7 @@ import org.apache.http.util.Args; * * @since 4.1 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class ManagedHttpCacheStorage implements HttpCacheStorage, Closeable { private final CacheMap entries; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/OptionsHttp11Response.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/OptionsHttp11Response.java index 2245360ea..39fba6be5 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/OptionsHttp11Response.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/OptionsHttp11Response.java @@ -36,7 +36,8 @@ import org.apache.http.HttpStatus; import org.apache.http.HttpVersion; import org.apache.http.ProtocolVersion; import org.apache.http.StatusLine; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.message.AbstractHttpMessage; import org.apache.http.message.BasicStatusLine; import org.apache.http.params.BasicHttpParams; @@ -46,7 +47,7 @@ import org.apache.http.params.HttpParams; * @since 4.1 */ @SuppressWarnings("deprecation") -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) final class OptionsHttp11Response extends AbstractHttpMessage implements HttpResponse { private final StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/Proxies.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/Proxies.java index c86a03916..c17521b5c 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/Proxies.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/Proxies.java @@ -29,7 +29,6 @@ package org.apache.http.impl.client.cache; import java.lang.reflect.Proxy; import org.apache.http.HttpResponse; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.util.Args; @@ -38,7 +37,6 @@ import org.apache.http.util.Args; * * @since 4.3 */ -@NotThreadSafe class Proxies { public static CloseableHttpResponse enhanceResponse(final HttpResponse original) { diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java index c74a607df..a50dc8cac 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java @@ -38,7 +38,8 @@ import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.HttpVersion; import org.apache.http.ProtocolVersion; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.cache.HeaderConstants; import org.apache.http.client.methods.HttpRequestWrapper; @@ -52,7 +53,7 @@ import org.apache.http.protocol.HTTP; /** * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) class RequestProtocolCompliance { private final boolean weakETagOnPutDeleteAllowed; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResourceReference.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResourceReference.java index 4f9ac4420..e9f2cf912 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResourceReference.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResourceReference.java @@ -29,12 +29,13 @@ package org.apache.http.impl.client.cache; import java.lang.ref.PhantomReference; import java.lang.ref.ReferenceQueue; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HttpCacheEntry; import org.apache.http.client.cache.Resource; import org.apache.http.util.Args; -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) class ResourceReference extends PhantomReference { private final Resource resource; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseCachingPolicy.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseCachingPolicy.java index ae7a08b7b..bbcb5d16b 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseCachingPolicy.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseCachingPolicy.java @@ -40,7 +40,8 @@ import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.HttpVersion; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.cache.HeaderConstants; import org.apache.http.client.utils.DateUtils; import org.apache.http.protocol.HTTP; @@ -50,7 +51,7 @@ import org.apache.http.protocol.HTTP; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) class ResponseCachingPolicy { private static final String[] AUTH_CACHEABLE_PARAMS = { diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java index bde392da7..c7e2785db 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java @@ -39,7 +39,8 @@ import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.HttpVersion; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.cache.HeaderConstants; import org.apache.http.client.methods.HttpRequestWrapper; @@ -50,7 +51,7 @@ import org.apache.http.protocol.HTTP; /** * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) class ResponseProtocolCompliance { private static final String UNEXPECTED_100_CONTINUE = "The incoming request did not contain a " diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java index 26f3c9da3..5b491c3a0 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java @@ -34,7 +34,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.apache.http.HttpResponse; -import org.apache.http.annotation.NotThreadSafe; /** * A proxy class that can enhance an arbitrary {@link HttpResponse} with @@ -42,7 +41,6 @@ import org.apache.http.annotation.NotThreadSafe; * * @since 4.3 */ -@NotThreadSafe class ResponseProxyHandler implements InvocationHandler { private static final Method CLOSE_METHOD; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/SizeLimitedResponseReader.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/SizeLimitedResponseReader.java index 4cb520a9b..f02e608bf 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/SizeLimitedResponseReader.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/SizeLimitedResponseReader.java @@ -33,7 +33,6 @@ import java.lang.reflect.Proxy; import org.apache.http.HttpEntity; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.client.cache.InputLimit; import org.apache.http.client.cache.Resource; import org.apache.http.client.cache.ResourceFactory; @@ -43,7 +42,6 @@ import org.apache.http.message.BasicHttpResponse; /** * @since 4.1 */ -@NotThreadSafe class SizeLimitedResponseReader { private final ResourceFactory resourceFactory; diff --git a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/CurrentWindowsCredentials.java b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/CurrentWindowsCredentials.java index 817499232..335d0c9be 100644 --- a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/CurrentWindowsCredentials.java +++ b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/CurrentWindowsCredentials.java @@ -30,7 +30,8 @@ package org.apache.http.impl.auth.win; import java.io.Serializable; import java.security.Principal; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.Credentials; import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT; @@ -44,7 +45,7 @@ import com.sun.jna.platform.win32.Secur32Util; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public final class CurrentWindowsCredentials implements Credentials, Serializable, Principal { private static final long serialVersionUID = 4361166468529298169L; diff --git a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsCredentialsProvider.java b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsCredentialsProvider.java index aae9e229f..f7921ea87 100644 --- a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsCredentialsProvider.java +++ b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsCredentialsProvider.java @@ -26,7 +26,8 @@ */ package org.apache.http.impl.auth.win; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScope; import org.apache.http.auth.Credentials; import org.apache.http.client.CredentialsProvider; @@ -43,7 +44,7 @@ import org.apache.http.util.Args; * * @since 4.4 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class WindowsCredentialsProvider implements CredentialsProvider { private final CredentialsProvider provider; diff --git a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNTLMSchemeFactory.java b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNTLMSchemeFactory.java index 21bed6409..724b935b6 100644 --- a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNTLMSchemeFactory.java +++ b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNTLMSchemeFactory.java @@ -27,7 +27,8 @@ package org.apache.http.impl.auth.win; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthSchemeProvider; import org.apache.http.client.config.AuthSchemes; @@ -42,7 +43,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class WindowsNTLMSchemeFactory implements AuthSchemeProvider { private final String servicePrincipalName; diff --git a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java index 3b0223f22..7e8b86612 100644 --- a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java +++ b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java @@ -32,7 +32,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.http.Header; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.Credentials; @@ -67,7 +66,6 @@ import com.sun.jna.ptr.IntByReference; * * @since 4.4 */ -@NotThreadSafe public class WindowsNegotiateScheme extends AuthSchemeBase { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateSchemeFactory.java b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateSchemeFactory.java index 29e5ffdb5..e719b8f92 100644 --- a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateSchemeFactory.java +++ b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateSchemeFactory.java @@ -27,7 +27,8 @@ package org.apache.http.impl.auth.win; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthSchemeProvider; import org.apache.http.client.config.AuthSchemes; @@ -42,7 +43,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class WindowsNegotiateSchemeFactory implements AuthSchemeProvider { private final String servicePrincipalName; diff --git a/httpclient/src/main/java-deprecated/org/apache/http/auth/params/AuthParams.java b/httpclient/src/main/java-deprecated/org/apache/http/auth/params/AuthParams.java index a7de77000..8312ae7d4 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/auth/params/AuthParams.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/auth/params/AuthParams.java @@ -27,7 +27,8 @@ package org.apache.http.auth.params; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.params.HttpParams; import org.apache.http.protocol.HTTP; import org.apache.http.util.Args; @@ -42,7 +43,7 @@ import org.apache.http.util.Args; * and constructor parameters of * {@link org.apache.http.auth.AuthSchemeProvider}s. */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public final class AuthParams { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/client/params/AuthPolicy.java b/httpclient/src/main/java-deprecated/org/apache/http/client/params/AuthPolicy.java index 768ddf991..a4cad330d 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/client/params/AuthPolicy.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/client/params/AuthPolicy.java @@ -27,8 +27,6 @@ package org.apache.http.client.params; -import org.apache.http.annotation.Immutable; - /** * Standard authentication schemes supported by HttpClient. * @@ -37,7 +35,6 @@ import org.apache.http.annotation.Immutable; * @deprecated (4.3) use {@link org.apache.http.client.config.AuthSchemes}. */ @Deprecated -@Immutable public final class AuthPolicy { private AuthPolicy() { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/client/params/ClientParamBean.java b/httpclient/src/main/java-deprecated/org/apache/http/client/params/ClientParamBean.java index 99ba8510e..7a84c7718 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/client/params/ClientParamBean.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/client/params/ClientParamBean.java @@ -31,7 +31,6 @@ import java.util.Collection; import org.apache.http.Header; import org.apache.http.HttpHost; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.params.HttpAbstractParamBean; import org.apache.http.params.HttpParams; @@ -45,7 +44,6 @@ import org.apache.http.params.HttpParams; * @deprecated (4.3) use {@link org.apache.http.client.config.RequestConfig}. */ @Deprecated -@NotThreadSafe public class ClientParamBean extends HttpAbstractParamBean { public ClientParamBean (final HttpParams params) { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/client/params/CookiePolicy.java b/httpclient/src/main/java-deprecated/org/apache/http/client/params/CookiePolicy.java index e12ab426d..505439edd 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/client/params/CookiePolicy.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/client/params/CookiePolicy.java @@ -27,8 +27,6 @@ package org.apache.http.client.params; -import org.apache.http.annotation.Immutable; - /** * Standard cookie specifications supported by HttpClient. * @@ -37,7 +35,6 @@ import org.apache.http.annotation.Immutable; * @deprecated (4.3) use {@link org.apache.http.client.config.CookieSpecs}. */ @Deprecated -@Immutable public final class CookiePolicy { /** diff --git a/httpclient/src/main/java-deprecated/org/apache/http/client/params/HttpClientParams.java b/httpclient/src/main/java-deprecated/org/apache/http/client/params/HttpClientParams.java index c27cb7f93..50a12f95a 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/client/params/HttpClientParams.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/client/params/HttpClientParams.java @@ -26,7 +26,6 @@ */ package org.apache.http.client.params; -import org.apache.http.annotation.Immutable; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; import org.apache.http.util.Args; @@ -39,7 +38,6 @@ import org.apache.http.util.Args; * @deprecated (4.3) use {@link org.apache.http.client.config.RequestConfig} */ @Deprecated -@Immutable public class HttpClientParams { private HttpClientParams() { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/ClientContextConfigurer.java b/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/ClientContextConfigurer.java index 39645ec40..6476a6bd2 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/ClientContextConfigurer.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/ClientContextConfigurer.java @@ -27,7 +27,6 @@ package org.apache.http.client.protocol; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.AuthSchemeRegistry; import org.apache.http.client.CookieStore; import org.apache.http.client.CredentialsProvider; @@ -42,7 +41,6 @@ import org.apache.http.util.Args; * * @deprecated (4.3) use {@link HttpClientContext} */ -@NotThreadSafe @Deprecated public class ClientContextConfigurer implements ClientContext { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/RequestProxyAuthentication.java b/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/RequestProxyAuthentication.java index b5ef5ad64..942a9cd6f 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/RequestProxyAuthentication.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/RequestProxyAuthentication.java @@ -31,7 +31,8 @@ import java.io.IOException; import org.apache.http.HttpException; import org.apache.http.HttpRequest; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthState; import org.apache.http.conn.HttpRoutedConnection; @@ -49,7 +50,7 @@ import org.apache.http.util.Args; * @deprecated (4.3) use {@link org.apache.http.impl.auth.HttpAuthenticator}. */ @Deprecated -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RequestProxyAuthentication extends RequestAuthenticationBase { public RequestProxyAuthentication() { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/RequestTargetAuthentication.java b/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/RequestTargetAuthentication.java index 263ff5707..78f75d938 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/RequestTargetAuthentication.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/RequestTargetAuthentication.java @@ -31,7 +31,8 @@ import java.io.IOException; import org.apache.http.HttpException; import org.apache.http.HttpRequest; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthState; import org.apache.http.protocol.HttpContext; @@ -46,7 +47,7 @@ import org.apache.http.util.Args; * @deprecated (4.3) use {@link org.apache.http.impl.auth.HttpAuthenticator}. */ @Deprecated -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RequestTargetAuthentication extends RequestAuthenticationBase { public RequestTargetAuthentication() { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/ResponseAuthCache.java b/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/ResponseAuthCache.java index 23322e8a8..2a4ec3d67 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/ResponseAuthCache.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/client/protocol/ResponseAuthCache.java @@ -35,7 +35,8 @@ import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.HttpResponseInterceptor; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthState; import org.apache.http.client.AuthCache; @@ -57,7 +58,7 @@ import org.apache.http.util.Args; * * @deprecated (4.2) use {@link org.apache.http.client.AuthenticationStrategy} */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class ResponseAuthCache implements HttpResponseInterceptor { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/client/utils/JdkIdn.java b/httpclient/src/main/java-deprecated/org/apache/http/client/utils/JdkIdn.java index 99898b827..427fcf89c 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/client/utils/JdkIdn.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/client/utils/JdkIdn.java @@ -29,7 +29,8 @@ package org.apache.http.client.utils; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * Uses the java.net.IDN class through reflection. @@ -38,7 +39,7 @@ import org.apache.http.annotation.Immutable; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class JdkIdn implements Idn { private final Method toUnicode; diff --git a/httpclient/src/main/java-deprecated/org/apache/http/client/utils/Punycode.java b/httpclient/src/main/java-deprecated/org/apache/http/client/utils/Punycode.java index 2d17f3459..58eb674c1 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/client/utils/Punycode.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/client/utils/Punycode.java @@ -26,7 +26,8 @@ */ package org.apache.http.client.utils; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * Facade that provides conversion between Unicode and Punycode domain names. @@ -36,7 +37,7 @@ import org.apache.http.annotation.Immutable; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class Punycode { private static final Idn impl; diff --git a/httpclient/src/main/java-deprecated/org/apache/http/client/utils/Rfc3492Idn.java b/httpclient/src/main/java-deprecated/org/apache/http/client/utils/Rfc3492Idn.java index 29dabc471..66ff45a39 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/client/utils/Rfc3492Idn.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/client/utils/Rfc3492Idn.java @@ -28,7 +28,8 @@ package org.apache.http.client.utils; import java.util.StringTokenizer; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * Implementation from pseudo code in RFC 3492. @@ -37,7 +38,7 @@ import org.apache.http.annotation.Immutable; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class Rfc3492Idn implements Idn { private static final int base = 36; diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/BasicEofSensorWatcher.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/BasicEofSensorWatcher.java index 9fa2c331c..6b64f3757 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/conn/BasicEofSensorWatcher.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/BasicEofSensorWatcher.java @@ -29,7 +29,6 @@ package org.apache.http.conn; import java.io.IOException; import java.io.InputStream; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.util.Args; /** @@ -41,7 +40,6 @@ import org.apache.http.util.Args; * @deprecated (4.3) do not use. */ @Deprecated -@NotThreadSafe public class BasicEofSensorWatcher implements EofSensorWatcher { /** The connection to auto-release. */ diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/BasicManagedEntity.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/BasicManagedEntity.java index 24dca916b..93765e7eb 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/conn/BasicManagedEntity.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/BasicManagedEntity.java @@ -32,7 +32,6 @@ import java.io.OutputStream; import java.net.SocketException; import org.apache.http.HttpEntity; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.entity.HttpEntityWrapper; import org.apache.http.util.Args; import org.apache.http.util.EntityUtils; @@ -48,7 +47,6 @@ import org.apache.http.util.EntityUtils; * @deprecated (4.3) do not use. */ @Deprecated -@NotThreadSafe public class BasicManagedEntity extends HttpEntityWrapper implements ConnectionReleaseTrigger, EofSensorWatcher { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/MultihomePlainSocketFactory.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/MultihomePlainSocketFactory.java index 7ce6e0500..92a6258d0 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/conn/MultihomePlainSocketFactory.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/MultihomePlainSocketFactory.java @@ -37,7 +37,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.scheme.SocketFactory; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; @@ -57,7 +58,7 @@ import org.apache.http.util.Asserts; * {@link org.apache.http.conn.scheme.SchemeSocketFactory} interface. */ @Deprecated -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public final class MultihomePlainSocketFactory implements SocketFactory { /** diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnManagerParamBean.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnManagerParamBean.java index 2dd56a057..d05d4617e 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnManagerParamBean.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnManagerParamBean.java @@ -27,7 +27,6 @@ package org.apache.http.conn.params; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.params.HttpAbstractParamBean; import org.apache.http.params.HttpParams; @@ -40,7 +39,6 @@ import org.apache.http.params.HttpParams; * * @deprecated (4.1) use configuration methods of the specific connection manager implementation. */ -@NotThreadSafe @Deprecated public class ConnManagerParamBean extends HttpAbstractParamBean { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnManagerParams.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnManagerParams.java index 3c4ddfb87..0529aefda 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnManagerParams.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnManagerParams.java @@ -26,7 +26,8 @@ */ package org.apache.http.conn.params; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.params.HttpParams; import org.apache.http.util.Args; @@ -42,7 +43,7 @@ import org.apache.http.util.Args; * @deprecated (4.1) use configuration methods of the specific connection manager implementation. */ @Deprecated -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public final class ConnManagerParams implements ConnManagerPNames { /** The default maximum number of connections allowed overall */ diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnPerRouteBean.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnPerRouteBean.java index 241424f5b..68e052f6e 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnPerRouteBean.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnPerRouteBean.java @@ -29,7 +29,8 @@ package org.apache.http.conn.params; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.util.Args; @@ -44,7 +45,7 @@ import org.apache.http.util.Args; * @deprecated (4.2) use {@link org.apache.http.pool.ConnPoolControl} */ @Deprecated -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public final class ConnPerRouteBean implements ConnPerRoute { /** The default maximum number of connections allowed per host */ diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnRouteParamBean.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnRouteParamBean.java index f574c7156..e75c8c470 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnRouteParamBean.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnRouteParamBean.java @@ -30,7 +30,6 @@ package org.apache.http.conn.params; import java.net.InetAddress; import org.apache.http.HttpHost; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.params.HttpAbstractParamBean; import org.apache.http.params.HttpParams; @@ -45,7 +44,6 @@ import org.apache.http.params.HttpParams; * @deprecated (4.3) use {@link org.apache.http.client.config.RequestConfig}. */ @Deprecated -@NotThreadSafe public class ConnRouteParamBean extends HttpAbstractParamBean { public ConnRouteParamBean (final HttpParams params) { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnRouteParams.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnRouteParams.java index c4a9bc1de..d28eb6841 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnRouteParams.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/params/ConnRouteParams.java @@ -29,7 +29,8 @@ package org.apache.http.conn.params; import java.net.InetAddress; import org.apache.http.HttpHost; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.params.HttpParams; import org.apache.http.util.Args; @@ -43,7 +44,7 @@ import org.apache.http.util.Args; * @deprecated (4.3) use {@link org.apache.http.client.config.RequestConfig}. */ @Deprecated -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class ConnRouteParams implements ConnRoutePNames { /** diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/PlainSocketFactory.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/PlainSocketFactory.java index a6973b169..f17415232 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/PlainSocketFactory.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/scheme/PlainSocketFactory.java @@ -34,7 +34,8 @@ import java.net.Socket; import java.net.SocketTimeoutException; import java.net.UnknownHostException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.ConnectTimeoutException; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; @@ -47,7 +48,7 @@ import org.apache.http.util.Args; * * @deprecated (4.3) use {@link org.apache.http.conn.socket.PlainConnectionSocketFactory} */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class PlainSocketFactory implements SocketFactory, SchemeSocketFactory { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLContextBuilder.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLContextBuilder.java index c54db0c52..fec0ca08e 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLContextBuilder.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLContextBuilder.java @@ -51,8 +51,6 @@ import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509KeyManager; import javax.net.ssl.X509TrustManager; -import org.apache.http.annotation.NotThreadSafe; - /** * Builder for {@link SSLContext} instances. * @@ -60,7 +58,6 @@ import org.apache.http.annotation.NotThreadSafe; * * @deprecated (4.4) use {@link org.apache.http.ssl.SSLContextBuilder}. */ -@NotThreadSafe @Deprecated public class SSLContextBuilder { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLContexts.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLContexts.java index 26ab3e500..e0a482eaa 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLContexts.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLContexts.java @@ -32,7 +32,8 @@ import java.security.NoSuchAlgorithmException; import javax.net.ssl.SSLContext; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * {@link SSLContext} factory methods. @@ -41,7 +42,7 @@ import org.apache.http.annotation.Immutable; * * @deprecated (4.4) use {@link org.apache.http.ssl.SSLContexts}. */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class SSLContexts { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java index 03fbe6801..8c7fee5a5 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java @@ -44,7 +44,8 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; import org.apache.http.HttpHost; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.ConnectTimeoutException; import org.apache.http.conn.HttpInetSocketAddress; import org.apache.http.conn.scheme.HostNameResolver; @@ -140,7 +141,7 @@ import org.apache.http.util.TextUtils; * * @deprecated (4.3) use {@link SSLConnectionSocketFactory}. */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) @Deprecated public class SSLSocketFactory implements LayeredConnectionSocketFactory, SchemeLayeredSocketFactory, LayeredSchemeSocketFactory, LayeredSocketFactory { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/cookie/params/CookieSpecParamBean.java b/httpclient/src/main/java-deprecated/org/apache/http/cookie/params/CookieSpecParamBean.java index ea6a9299e..917c054fd 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/cookie/params/CookieSpecParamBean.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/cookie/params/CookieSpecParamBean.java @@ -29,7 +29,6 @@ package org.apache.http.cookie.params; import java.util.Collection; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.params.HttpAbstractParamBean; import org.apache.http.params.HttpParams; @@ -44,7 +43,6 @@ import org.apache.http.params.HttpParams; * org.apache.http.cookie.CookieSpecProvider}s. */ @Deprecated -@NotThreadSafe public class CookieSpecParamBean extends HttpAbstractParamBean { public CookieSpecParamBean (final HttpParams params) { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AbstractAuthenticationHandler.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AbstractAuthenticationHandler.java index c3af00dff..7f020749a 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AbstractAuthenticationHandler.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AbstractAuthenticationHandler.java @@ -40,7 +40,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.http.FormattedHeader; import org.apache.http.Header; import org.apache.http.HttpResponse; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthSchemeRegistry; import org.apache.http.auth.AuthenticationException; @@ -61,7 +62,7 @@ import org.apache.http.util.CharArrayBuffer; * @deprecated (4.2) use {@link org.apache.http.client.AuthenticationStrategy} */ @Deprecated -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public abstract class AbstractAuthenticationHandler implements AuthenticationHandler { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AbstractHttpClient.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AbstractHttpClient.java index f64fa8bb0..35a669fcc 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AbstractHttpClient.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AbstractHttpClient.java @@ -38,8 +38,8 @@ import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpRequestInterceptor; import org.apache.http.HttpResponseInterceptor; -import org.apache.http.annotation.GuardedBy; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthSchemeRegistry; import org.apache.http.client.AuthenticationHandler; import org.apache.http.client.AuthenticationStrategy; @@ -194,85 +194,30 @@ import org.apache.http.util.Args; * * @deprecated (4.3) use {@link HttpClientBuilder}. */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) @Deprecated public abstract class AbstractHttpClient extends CloseableHttpClient { private final Log log = LogFactory.getLog(getClass()); - /** The parameters. */ - @GuardedBy("this") private HttpParams defaultParams; - - /** The request executor. */ - @GuardedBy("this") private HttpRequestExecutor requestExec; - - /** The connection manager. */ - @GuardedBy("this") private ClientConnectionManager connManager; - - /** The connection re-use strategy. */ - @GuardedBy("this") private ConnectionReuseStrategy reuseStrategy; - - /** The connection keep-alive strategy. */ - @GuardedBy("this") private ConnectionKeepAliveStrategy keepAliveStrategy; - - /** The cookie spec registry. */ - @GuardedBy("this") private CookieSpecRegistry supportedCookieSpecs; - - /** The authentication scheme registry. */ - @GuardedBy("this") private AuthSchemeRegistry supportedAuthSchemes; - - /** The HTTP protocol processor and its immutable copy. */ - @GuardedBy("this") private BasicHttpProcessor mutableProcessor; - - @GuardedBy("this") private ImmutableHttpProcessor protocolProcessor; - - /** The request retry handler. */ - @GuardedBy("this") private HttpRequestRetryHandler retryHandler; - - /** The redirect handler. */ - @GuardedBy("this") private RedirectStrategy redirectStrategy; - - /** The target authentication handler. */ - @GuardedBy("this") private AuthenticationStrategy targetAuthStrategy; - - /** The proxy authentication handler. */ - @GuardedBy("this") private AuthenticationStrategy proxyAuthStrategy; - - /** The cookie store. */ - @GuardedBy("this") private CookieStore cookieStore; - - /** The credentials provider. */ - @GuardedBy("this") private CredentialsProvider credsProvider; - - /** The route planner. */ - @GuardedBy("this") private HttpRoutePlanner routePlanner; - - /** The user token handler. */ - @GuardedBy("this") private UserTokenHandler userTokenHandler; - - /** The connection backoff strategy. */ - @GuardedBy("this") private ConnectionBackoffStrategy connectionBackoffStrategy; - - /** The backoff manager. */ - @GuardedBy("this") private BackoffManager backoffManager; /** diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AuthenticationStrategyAdaptor.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AuthenticationStrategyAdaptor.java index 2ff4ccf4d..f72ae07f6 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AuthenticationStrategyAdaptor.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AuthenticationStrategyAdaptor.java @@ -37,7 +37,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.http.Header; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthOption; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthScope; @@ -56,7 +57,7 @@ import org.apache.http.util.Args; /** * @deprecated (4.2) do not use */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated class AuthenticationStrategyAdaptor implements AuthenticationStrategy { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AutoRetryHttpClient.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AutoRetryHttpClient.java index 272872a67..5c0b86402 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AutoRetryHttpClient.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/AutoRetryHttpClient.java @@ -36,7 +36,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.HttpClient; import org.apache.http.client.ResponseHandler; import org.apache.http.client.ServiceUnavailableRetryStrategy; @@ -56,7 +57,7 @@ import org.apache.http.util.EntityUtils; * @deprecated (4.3) use {@link HttpClientBuilder}. */ @Deprecated -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) public class AutoRetryHttpClient implements HttpClient { private final HttpClient backend; diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/ClientParamsStack.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/ClientParamsStack.java index 65f80d25a..ea57a789a 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/ClientParamsStack.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/ClientParamsStack.java @@ -27,7 +27,6 @@ package org.apache.http.impl.client; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.params.AbstractHttpParams; import org.apache.http.params.HttpParams; import org.apache.http.util.Args; @@ -69,7 +68,6 @@ import org.apache.http.util.Args; * @deprecated (4.3) use configuration classes provided 'org.apache.http.config' * and 'org.apache.http.client.config' */ -@NotThreadSafe @Deprecated public class ClientParamsStack extends AbstractHttpParams { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/CloseableHttpResponseProxy.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/CloseableHttpResponseProxy.java index aa3fcec7a..649d35927 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/CloseableHttpResponseProxy.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/CloseableHttpResponseProxy.java @@ -36,7 +36,6 @@ import java.lang.reflect.Proxy; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.util.EntityUtils; @@ -44,7 +43,6 @@ import org.apache.http.util.EntityUtils; * @since 4.3 */ @Deprecated -@NotThreadSafe class CloseableHttpResponseProxy implements InvocationHandler { private final static Constructor CONSTRUCTOR; diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/ContentEncodingHttpClient.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/ContentEncodingHttpClient.java index 4f1bd33ed..784106454 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/ContentEncodingHttpClient.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/ContentEncodingHttpClient.java @@ -26,7 +26,8 @@ */ package org.apache.http.impl.client; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.protocol.RequestAcceptEncoding; import org.apache.http.client.protocol.ResponseContentEncoding; import org.apache.http.conn.ClientConnectionManager; @@ -50,7 +51,7 @@ import org.apache.http.protocol.BasicHttpProcessor; * @deprecated (4.2) use {@link HttpClientBuilder} */ @Deprecated -@ThreadSafe // since DefaultHttpClient is +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) // since DefaultHttpClient is public class ContentEncodingHttpClient extends DefaultHttpClient { /** diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultHttpClient.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultHttpClient.java index e64b008bf..389bc3a50 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultHttpClient.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultHttpClient.java @@ -28,7 +28,8 @@ package org.apache.http.impl.client; import org.apache.http.HttpVersion; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.protocol.RequestAddCookies; import org.apache.http.client.protocol.RequestAuthCache; import org.apache.http.client.protocol.RequestClientConnControl; @@ -112,7 +113,7 @@ import org.apache.http.util.VersionInfo; * * @deprecated (4.3) use {@link HttpClientBuilder} see also {@link CloseableHttpClient}. */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) @Deprecated public class DefaultHttpClient extends AbstractHttpClient { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java index 14ce013e1..1491a0930 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java @@ -33,7 +33,8 @@ import java.util.Map; import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AUTH; import org.apache.http.auth.MalformedChallengeException; import org.apache.http.auth.params.AuthPNames; @@ -49,7 +50,7 @@ import org.apache.http.util.Args; * @deprecated (4.2) use {@link ProxyAuthenticationStrategy} */ @Deprecated -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class DefaultProxyAuthenticationHandler extends AbstractAuthenticationHandler { public DefaultProxyAuthenticationHandler() { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRedirectHandler.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRedirectHandler.java index 228b69096..0c1e7b70b 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRedirectHandler.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRedirectHandler.java @@ -38,7 +38,8 @@ import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.CircularRedirectException; import org.apache.http.client.RedirectHandler; import org.apache.http.client.methods.HttpGet; @@ -58,7 +59,7 @@ import org.apache.http.util.Asserts; * * @deprecated (4.1) use {@link DefaultRedirectStrategy}. */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class DefaultRedirectHandler implements RedirectHandler { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRedirectStrategyAdaptor.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRedirectStrategyAdaptor.java index d87090fc3..41ef7ed1d 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRedirectStrategyAdaptor.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRedirectStrategyAdaptor.java @@ -32,7 +32,8 @@ import java.net.URI; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.RedirectHandler; import org.apache.http.client.RedirectStrategy; import org.apache.http.client.methods.HttpGet; @@ -43,7 +44,7 @@ import org.apache.http.protocol.HttpContext; /** * @deprecated (4.1) do not use */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated class DefaultRedirectStrategyAdaptor implements RedirectStrategy { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRequestDirector.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRequestDirector.java index ed233b293..45cb9988e 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRequestDirector.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRequestDirector.java @@ -45,7 +45,6 @@ import org.apache.http.HttpResponse; import org.apache.http.NoHttpResponseException; import org.apache.http.ProtocolException; import org.apache.http.ProtocolVersion; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.AuthProtocolState; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthState; @@ -132,7 +131,6 @@ import org.apache.http.util.EntityUtils; * @deprecated (4.3) */ @Deprecated -@NotThreadSafe // e.g. managedConn public class DefaultRequestDirector implements RequestDirector { private final Log log; diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java index c47f9e084..b4499c957 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java @@ -33,7 +33,8 @@ import java.util.Map; import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AUTH; import org.apache.http.auth.MalformedChallengeException; import org.apache.http.auth.params.AuthPNames; @@ -49,7 +50,7 @@ import org.apache.http.util.Args; * @deprecated (4.2) use {@link TargetAuthenticationStrategy} */ @Deprecated -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class DefaultTargetAuthenticationHandler extends AbstractAuthenticationHandler { public DefaultTargetAuthenticationHandler() { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/RoutedRequest.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/RoutedRequest.java index 43a0a80a0..4c5440302 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/RoutedRequest.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/RoutedRequest.java @@ -27,7 +27,6 @@ package org.apache.http.impl.client; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.conn.routing.HttpRoute; /** @@ -38,11 +37,10 @@ import org.apache.http.conn.routing.HttpRoute; * @deprecated (4.3) do not use. */ @Deprecated -@NotThreadSafe // RequestWrapper is @NotThreadSafe public class RoutedRequest { protected final RequestWrapper request; // @NotThreadSafe - protected final HttpRoute route; // @Immutable + protected final HttpRoute route; // @Contract(threading = ThreadingBehavior.IMMUTABLE) /** * Creates a new routed request. diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/SystemDefaultHttpClient.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/SystemDefaultHttpClient.java index 0d3c58186..b8cecf22c 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/SystemDefaultHttpClient.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/SystemDefaultHttpClient.java @@ -30,7 +30,8 @@ package org.apache.http.impl.client; import java.net.ProxySelector; import org.apache.http.ConnectionReuseStrategy; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.routing.HttpRoutePlanner; import org.apache.http.impl.DefaultConnectionReuseStrategy; @@ -104,7 +105,7 @@ import org.apache.http.params.HttpParams; * * @deprecated (4.3) use {@link HttpClientBuilder} */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) @Deprecated public class SystemDefaultHttpClient extends DefaultHttpClient { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/TunnelRefusedException.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/TunnelRefusedException.java index 0a6f134dd..b1e634e29 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/client/TunnelRefusedException.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/client/TunnelRefusedException.java @@ -29,7 +29,6 @@ package org.apache.http.impl.client; import org.apache.http.HttpException; import org.apache.http.HttpResponse; -import org.apache.http.annotation.Immutable; /** * Signals that the tunnel request was rejected by the proxy host. @@ -39,7 +38,6 @@ import org.apache.http.annotation.Immutable; * @deprecated (4.3) reserved for internal use. */ @Deprecated -@Immutable public class TunnelRefusedException extends HttpException { private static final long serialVersionUID = -8646722842745617323L; diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/AbstractClientConnAdapter.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/AbstractClientConnAdapter.java index 5a1827af1..3f2a420de 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/AbstractClientConnAdapter.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/AbstractClientConnAdapter.java @@ -40,7 +40,6 @@ import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpException; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.ManagedClientConnection; import org.apache.http.conn.OperatedClientConnection; @@ -70,7 +69,6 @@ import org.apache.http.protocol.HttpContext; * @deprecated (4.2) do not use */ @Deprecated -@NotThreadSafe public abstract class AbstractClientConnAdapter implements ManagedClientConnection, HttpContext { /** diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java index 9e424a48c..3e158ab23 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java @@ -34,8 +34,8 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpClientConnection; -import org.apache.http.annotation.GuardedBy; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.ClientConnectionOperator; import org.apache.http.conn.ClientConnectionRequest; @@ -66,7 +66,7 @@ import org.apache.http.util.Asserts; * * @deprecated (4.3) use {@link BasicHttpClientConnectionManager}. */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) @Deprecated public class BasicClientConnectionManager implements ClientConnectionManager { @@ -86,15 +86,12 @@ public class BasicClientConnectionManager implements ClientConnectionManager { private final ClientConnectionOperator connOperator; /** The one and only entry in this pool. */ - @GuardedBy("this") private HttpPoolEntry poolEntry; /** The currently issued managed connection, if any. */ - @GuardedBy("this") private ManagedClientConnectionImpl conn; /** Indicates whether this connection manager is shut down. */ - @GuardedBy("this") private volatile boolean shutdown; /** diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultClientConnection.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultClientConnection.java index 5a29784c4..081f0671c 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultClientConnection.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultClientConnection.java @@ -44,9 +44,8 @@ import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpResponseFactory; -import org.apache.http.annotation.NotThreadSafe; -import org.apache.http.conn.OperatedClientConnection; import org.apache.http.conn.ManagedHttpClientConnection; +import org.apache.http.conn.OperatedClientConnection; import org.apache.http.impl.SocketHttpClientConnection; import org.apache.http.io.HttpMessageParser; import org.apache.http.io.SessionInputBuffer; @@ -64,7 +63,6 @@ import org.apache.http.util.Args; * * @deprecated (4.3) use {@link ManagedHttpClientConnectionFactory}. */ -@NotThreadSafe // connSecure, targetHost @Deprecated public class DefaultClientConnection extends SocketHttpClientConnection implements OperatedClientConnection, ManagedHttpClientConnection, HttpContext { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultClientConnectionOperator.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultClientConnectionOperator.java index ee14079f1..5eaac1352 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultClientConnectionOperator.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultClientConnectionOperator.java @@ -37,7 +37,8 @@ import java.net.UnknownHostException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpHost; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.protocol.ClientContext; import org.apache.http.conn.ClientConnectionOperator; import org.apache.http.conn.ConnectTimeoutException; @@ -86,13 +87,13 @@ import org.apache.http.util.Asserts; * @deprecated (4.3) use {@link PoolingHttpClientConnectionManager}. */ @Deprecated -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) public class DefaultClientConnectionOperator implements ClientConnectionOperator { private final Log log = LogFactory.getLog(getClass()); /** The scheme registry for looking up socket factories. */ - protected final SchemeRegistry schemeRegistry; // @ThreadSafe + protected final SchemeRegistry schemeRegistry; // @Contract(threading = ThreadingBehavior.SAFE) /** the custom-configured DNS lookup mechanism. */ protected final DnsResolver dnsResolver; diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java index 650c20249..e0ac52eef 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java @@ -33,7 +33,8 @@ import java.net.InetAddress; import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.params.ConnRouteParams; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.conn.routing.HttpRoutePlanner; @@ -61,12 +62,12 @@ import org.apache.http.util.Asserts; * * @deprecated (4.3) use {@link DefaultRoutePlanner} */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) @Deprecated public class DefaultHttpRoutePlanner implements HttpRoutePlanner { /** The scheme registry. */ - protected final SchemeRegistry schemeRegistry; // class is @ThreadSafe + protected final SchemeRegistry schemeRegistry; // class is @Contract(threading = ThreadingBehavior.SAFE) /** * Creates a new default route planner. diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultResponseParser.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultResponseParser.java index 456c2953a..732c9e880 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultResponseParser.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultResponseParser.java @@ -37,7 +37,8 @@ import org.apache.http.HttpResponseFactory; import org.apache.http.NoHttpResponseException; import org.apache.http.ProtocolException; import org.apache.http.StatusLine; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.impl.io.AbstractMessageParser; import org.apache.http.io.SessionInputBuffer; import org.apache.http.message.LineParser; @@ -62,7 +63,7 @@ import org.apache.http.util.CharArrayBuffer; * @deprecated (4.2) use {@link DefaultHttpResponseParser} */ @Deprecated -@ThreadSafe // no public methods +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) public class DefaultResponseParser extends AbstractMessageParser { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/LoggingSessionInputBuffer.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/LoggingSessionInputBuffer.java index 470830670..a0b37ae13 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/LoggingSessionInputBuffer.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/LoggingSessionInputBuffer.java @@ -29,7 +29,8 @@ package org.apache.http.impl.conn; import java.io.IOException; import org.apache.http.Consts; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.io.EofSensor; import org.apache.http.io.HttpTransportMetrics; import org.apache.http.io.SessionInputBuffer; @@ -42,7 +43,7 @@ import org.apache.http.util.CharArrayBuffer; * * @deprecated (4.3) no longer used. */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class LoggingSessionInputBuffer implements SessionInputBuffer, EofSensor { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java index a4e991271..8c552e11c 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java @@ -29,7 +29,8 @@ package org.apache.http.impl.conn; import java.io.IOException; import org.apache.http.Consts; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.io.HttpTransportMetrics; import org.apache.http.io.SessionOutputBuffer; import org.apache.http.util.CharArrayBuffer; @@ -39,7 +40,7 @@ import org.apache.http.util.CharArrayBuffer; * @since 4.0 * @deprecated (4.3) no longer used. */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class LoggingSessionOutputBuffer implements SessionOutputBuffer { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/ManagedClientConnectionImpl.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/ManagedClientConnectionImpl.java index 7b5b70f92..dea2e11ff 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/ManagedClientConnectionImpl.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/ManagedClientConnectionImpl.java @@ -41,7 +41,6 @@ import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.ClientConnectionOperator; import org.apache.http.conn.ManagedClientConnection; @@ -59,7 +58,6 @@ import org.apache.http.util.Asserts; * @deprecated (4.3) use {@link ManagedHttpClientConnectionFactory}. */ @Deprecated -@NotThreadSafe class ManagedClientConnectionImpl implements ManagedClientConnection { private final ClientConnectionManager manager; diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java index a4e5f286a..3e2fefbbb 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java @@ -34,7 +34,8 @@ import java.util.concurrent.TimeoutException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.ClientConnectionOperator; import org.apache.http.conn.ClientConnectionRequest; @@ -69,7 +70,7 @@ import org.apache.http.util.Asserts; * @deprecated (4.3) use {@link PoolingHttpClientConnectionManager}. */ @Deprecated -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) public class PoolingClientConnectionManager implements ClientConnectionManager, ConnPoolControl { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java index 2fe96d1ff..be08daac7 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java @@ -39,7 +39,6 @@ import java.util.List; import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.conn.params.ConnRouteParams; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.conn.routing.HttpRoutePlanner; @@ -71,12 +70,11 @@ import org.apache.http.util.Asserts; * * @deprecated (4.3) use {@link SystemDefaultRoutePlanner} */ -@NotThreadSafe // e.g [gs]etProxySelector() @Deprecated public class ProxySelectorRoutePlanner implements HttpRoutePlanner { /** The scheme registry. */ - protected final SchemeRegistry schemeRegistry; // @ThreadSafe + protected final SchemeRegistry schemeRegistry; // @Contract(threading = ThreadingBehavior.SAFE) /** The proxy selector to use, or {@code null} for system default. */ protected ProxySelector proxySelector; diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SchemeRegistryFactory.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SchemeRegistryFactory.java index 06105dd19..7290728c1 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SchemeRegistryFactory.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SchemeRegistryFactory.java @@ -26,7 +26,8 @@ */ package org.apache.http.impl.conn; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.scheme.PlainSocketFactory; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; @@ -37,7 +38,7 @@ import org.apache.http.conn.ssl.SSLSocketFactory; * * @deprecated (4.3) use {@link org.apache.http.impl.client.HttpClientBuilder}. */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) @Deprecated public final class SchemeRegistryFactory { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java index 774cf4a37..2861b9b69 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java @@ -32,8 +32,8 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.annotation.GuardedBy; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.ClientConnectionOperator; import org.apache.http.conn.ClientConnectionRequest; @@ -61,7 +61,7 @@ import org.apache.http.util.Asserts; * * @deprecated (4.2) use {@link BasicClientConnectionManager} */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) @Deprecated public class SingleClientConnManager implements ClientConnectionManager { @@ -82,19 +82,15 @@ public class SingleClientConnManager implements ClientConnectionManager { protected final boolean alwaysShutDown; /** The one and only entry in this pool. */ - @GuardedBy("this") protected volatile PoolEntry uniquePoolEntry; /** The currently issued managed connection, if any. */ - @GuardedBy("this") protected volatile ConnAdapter managedConn; /** The time of the last connection release, or -1. */ - @GuardedBy("this") protected volatile long lastReleaseTime; /** The time the last released connection expires and shouldn't be reused. */ - @GuardedBy("this") protected volatile long connectionExpiresTime; /** Indicates whether this connection manager is shut down. */ diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java index c7e6243ca..d9dfbfe2b 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java @@ -38,7 +38,6 @@ import java.util.concurrent.locks.ReentrantLock; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.annotation.GuardedBy; import org.apache.http.conn.ConnectionPoolTimeoutException; import org.apache.http.conn.OperatedClientConnection; import org.apache.http.conn.routing.HttpRoute; @@ -66,12 +65,8 @@ public abstract class AbstractConnPool { */ protected final Lock poolLock; - /** References to issued connections */ - @GuardedBy("poolLock") protected Set leasedConnections; - /** The current total number of connections. */ - @GuardedBy("poolLock") protected int numConnections; /** Indicates whether this pool is shut down. */ diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java index 222038080..c831f8d28 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java @@ -45,7 +45,7 @@ import org.apache.http.util.Args; public class BasicPoolEntryRef extends WeakReference { /** The planned route of the entry. */ - private final HttpRoute route; // HttpRoute is @Immutable + private final HttpRoute route; // HttpRoute is @Contract(threading = ThreadingBehavior.IMMUTABLE) /** diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java index 5bda67c36..74f11189c 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java @@ -31,7 +31,8 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.ClientConnectionOperator; import org.apache.http.conn.ClientConnectionRequest; @@ -66,14 +67,14 @@ import org.apache.http.util.Asserts; * * @deprecated (4.2) use {@link org.apache.http.impl.conn.PoolingHttpClientConnectionManager} */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) @Deprecated public class ThreadSafeClientConnManager implements ClientConnectionManager { private final Log log; /** The schemes supported by this connection manager. */ - protected final SchemeRegistry schemeRegistry; // @ThreadSafe + protected final SchemeRegistry schemeRegistry; // @Contract(threading = ThreadingBehavior.SAFE) protected final AbstractConnPool connectionPool; @@ -81,7 +82,7 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager { protected final ConnPoolByRoute pool; /** The operator for opening and updating connections. */ - protected final ClientConnectionOperator connOperator; // DefaultClientConnectionOperator is @ThreadSafe + protected final ClientConnectionOperator connOperator; // DefaultClientConnectionOperator is @Contract(threading = ThreadingBehavior.SAFE) protected final ConnPerRouteBean connPerRoute; @@ -206,7 +207,7 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager { protected ClientConnectionOperator createConnectionOperator(final SchemeRegistry schreg) { - return new DefaultClientConnectionOperator(schreg);// @ThreadSafe + return new DefaultClientConnectionOperator(schreg);// @Contract(threading = ThreadingBehavior.SAFE) } @Override diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BestMatchSpec.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BestMatchSpec.java index a21da60b3..5f829a575 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BestMatchSpec.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BestMatchSpec.java @@ -27,7 +27,8 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * 'Meta' cookie specification that picks up a cookie policy based on @@ -37,7 +38,7 @@ import org.apache.http.annotation.ThreadSafe; * * @since 4.0 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) @Deprecated public class BestMatchSpec extends DefaultCookieSpec { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BestMatchSpecFactory.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BestMatchSpecFactory.java index 7ad7f6327..e87f3d018 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BestMatchSpecFactory.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BestMatchSpecFactory.java @@ -29,7 +29,8 @@ package org.apache.http.impl.cookie; import java.util.Collection; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecFactory; import org.apache.http.cookie.CookieSpecProvider; @@ -46,7 +47,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class BestMatchSpecFactory implements CookieSpecFactory, CookieSpecProvider { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpec.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpec.java index 46d834d5e..fb559f7d3 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpec.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpec.java @@ -36,7 +36,8 @@ import org.apache.http.FormattedHeader; import org.apache.http.Header; import org.apache.http.HeaderElement; import org.apache.http.NameValuePair; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.utils.DateUtils; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieAttributeHandler; @@ -61,7 +62,7 @@ import org.apache.http.util.CharArrayBuffer; * @since 4.0 */ @Deprecated -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class BrowserCompatSpec extends CookieSpecBase { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java index a89908f22..7cb0f8895 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java @@ -29,7 +29,8 @@ package org.apache.http.impl.cookie; import java.util.Collection; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecFactory; import org.apache.http.cookie.CookieSpecProvider; @@ -46,7 +47,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class BrowserCompatSpecFactory implements CookieSpecFactory, CookieSpecProvider { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java index 387259ca8..0a68578fd 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java @@ -27,7 +27,8 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.MalformedCookieException; @@ -42,7 +43,7 @@ import org.apache.http.util.Args; * @since 4.3 */ @Deprecated -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class BrowserCompatVersionAttributeHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/DateParseException.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/DateParseException.java index e6d07bcba..aa2faec81 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/DateParseException.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/DateParseException.java @@ -27,8 +27,6 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; - /** * An exception to indicate an error parsing a date string. * @@ -40,7 +38,6 @@ import org.apache.http.annotation.Immutable; * @deprecated (4.3) no longer used. */ @Deprecated -@Immutable public class DateParseException extends Exception { private static final long serialVersionUID = 4417696455000643370L; diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/DateUtils.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/DateUtils.java index 57e0bd1de..22f5d0622 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/DateUtils.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/DateUtils.java @@ -30,8 +30,6 @@ package org.apache.http.impl.cookie; import java.util.Date; import java.util.TimeZone; -import org.apache.http.annotation.Immutable; - /** * A utility class for parsing and formatting HTTP dates as used in cookies and * other headers. This class handles dates as defined by RFC 2616 section @@ -43,7 +41,6 @@ import org.apache.http.annotation.Immutable; * @deprecated (4.3) Use {@link org.apache.http.client.utils.DateUtils}. */ @Deprecated -@Immutable public final class DateUtils { /** diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/IgnoreSpecFactory.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/IgnoreSpecFactory.java index 91052c1ff..835badf86 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/IgnoreSpecFactory.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/IgnoreSpecFactory.java @@ -27,7 +27,8 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecFactory; import org.apache.http.cookie.CookieSpecProvider; @@ -41,7 +42,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class IgnoreSpecFactory implements CookieSpecFactory, CookieSpecProvider { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java index e5e72d82d..a8a6f0413 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java @@ -29,7 +29,8 @@ package org.apache.http.impl.cookie; import java.util.Collection; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecFactory; import org.apache.http.cookie.CookieSpecProvider; @@ -46,7 +47,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class NetscapeDraftSpecFactory implements CookieSpecFactory, CookieSpecProvider { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/PublicSuffixListParser.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/PublicSuffixListParser.java index 210956c75..4c0458621 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/PublicSuffixListParser.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/PublicSuffixListParser.java @@ -29,7 +29,8 @@ package org.apache.http.impl.cookie; import java.io.IOException; import java.io.Reader; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.util.PublicSuffixList; /** @@ -40,7 +41,7 @@ import org.apache.http.conn.util.PublicSuffixList; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class PublicSuffixListParser { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2109SpecFactory.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2109SpecFactory.java index 278e24000..e6a3f79ba 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2109SpecFactory.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2109SpecFactory.java @@ -29,7 +29,8 @@ package org.apache.http.impl.cookie; import java.util.Collection; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecFactory; import org.apache.http.cookie.CookieSpecProvider; @@ -46,7 +47,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class RFC2109SpecFactory implements CookieSpecFactory, CookieSpecProvider { diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2965SpecFactory.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2965SpecFactory.java index 95ba80142..7ccfb97bb 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2965SpecFactory.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/cookie/RFC2965SpecFactory.java @@ -29,7 +29,8 @@ package org.apache.http.impl.cookie; import java.util.Collection; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecFactory; import org.apache.http.cookie.CookieSpecProvider; @@ -46,7 +47,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class RFC2965SpecFactory implements CookieSpecFactory, CookieSpecProvider { diff --git a/httpclient/src/main/java/org/apache/http/auth/AUTH.java b/httpclient/src/main/java/org/apache/http/auth/AUTH.java index 8ae454533..69fcc9ca9 100644 --- a/httpclient/src/main/java/org/apache/http/auth/AUTH.java +++ b/httpclient/src/main/java/org/apache/http/auth/AUTH.java @@ -27,15 +27,12 @@ package org.apache.http.auth; -import org.apache.http.annotation.Immutable; - /** * Constants and static helpers related to the HTTP authentication. * * * @since 4.0 */ -@Immutable public final class AUTH { /** diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthOption.java b/httpclient/src/main/java/org/apache/http/auth/AuthOption.java index 21f0bc965..ff5f5e9d2 100644 --- a/httpclient/src/main/java/org/apache/http/auth/AuthOption.java +++ b/httpclient/src/main/java/org/apache/http/auth/AuthOption.java @@ -26,13 +26,14 @@ */ package org.apache.http.auth; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; /** * @since 4.2 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public final class AuthOption { private final AuthScheme authScheme; diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java b/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java index d3dcddc5b..30a578eee 100644 --- a/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java +++ b/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java @@ -33,7 +33,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.http.HttpRequest; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.config.Lookup; import org.apache.http.params.HttpParams; import org.apache.http.protocol.ExecutionContext; @@ -48,7 +49,7 @@ import org.apache.http.util.Args; * * @deprecated (4.3) use {@link org.apache.http.config.Registry} */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) @Deprecated public final class AuthSchemeRegistry implements Lookup { diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthScope.java b/httpclient/src/main/java/org/apache/http/auth/AuthScope.java index 548854009..46f9cc485 100644 --- a/httpclient/src/main/java/org/apache/http/auth/AuthScope.java +++ b/httpclient/src/main/java/org/apache/http/auth/AuthScope.java @@ -29,7 +29,8 @@ package org.apache.http.auth; import java.util.Locale; import org.apache.http.HttpHost; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; import org.apache.http.util.LangUtils; @@ -42,7 +43,7 @@ import org.apache.http.util.LangUtils; *

* @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class AuthScope { /** diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthState.java b/httpclient/src/main/java/org/apache/http/auth/AuthState.java index 9b932e78e..64febf36f 100644 --- a/httpclient/src/main/java/org/apache/http/auth/AuthState.java +++ b/httpclient/src/main/java/org/apache/http/auth/AuthState.java @@ -28,7 +28,6 @@ package org.apache.http.auth; import java.util.Queue; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.util.Args; /** @@ -36,7 +35,6 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@NotThreadSafe public class AuthState { /** Actual state of authentication protocol */ diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthenticationException.java b/httpclient/src/main/java/org/apache/http/auth/AuthenticationException.java index 8d8e34c63..d8e2aa309 100644 --- a/httpclient/src/main/java/org/apache/http/auth/AuthenticationException.java +++ b/httpclient/src/main/java/org/apache/http/auth/AuthenticationException.java @@ -27,7 +27,6 @@ package org.apache.http.auth; import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; /** * Signals a failure in authentication process @@ -35,7 +34,6 @@ import org.apache.http.annotation.Immutable; * * @since 4.0 */ -@Immutable public class AuthenticationException extends ProtocolException { private static final long serialVersionUID = -6794031905674764776L; diff --git a/httpclient/src/main/java/org/apache/http/auth/BasicUserPrincipal.java b/httpclient/src/main/java/org/apache/http/auth/BasicUserPrincipal.java index 92bf4e6c9..d52538c48 100644 --- a/httpclient/src/main/java/org/apache/http/auth/BasicUserPrincipal.java +++ b/httpclient/src/main/java/org/apache/http/auth/BasicUserPrincipal.java @@ -29,7 +29,8 @@ package org.apache.http.auth; import java.io.Serializable; import java.security.Principal; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; import org.apache.http.util.LangUtils; @@ -38,7 +39,7 @@ import org.apache.http.util.LangUtils; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public final class BasicUserPrincipal implements Principal, Serializable { private static final long serialVersionUID = -2266305184969850467L; diff --git a/httpclient/src/main/java/org/apache/http/auth/InvalidCredentialsException.java b/httpclient/src/main/java/org/apache/http/auth/InvalidCredentialsException.java index e357241c1..44812bd7f 100644 --- a/httpclient/src/main/java/org/apache/http/auth/InvalidCredentialsException.java +++ b/httpclient/src/main/java/org/apache/http/auth/InvalidCredentialsException.java @@ -26,8 +26,6 @@ */ package org.apache.http.auth; -import org.apache.http.annotation.Immutable; - /** * Authentication credentials required to respond to a authentication * challenge are invalid @@ -35,7 +33,6 @@ import org.apache.http.annotation.Immutable; * * @since 4.0 */ -@Immutable public class InvalidCredentialsException extends AuthenticationException { private static final long serialVersionUID = -4834003835215460648L; diff --git a/httpclient/src/main/java/org/apache/http/auth/KerberosCredentials.java b/httpclient/src/main/java/org/apache/http/auth/KerberosCredentials.java index 16d0c5bf0..1ff5a62b5 100644 --- a/httpclient/src/main/java/org/apache/http/auth/KerberosCredentials.java +++ b/httpclient/src/main/java/org/apache/http/auth/KerberosCredentials.java @@ -29,7 +29,8 @@ package org.apache.http.auth; import java.io.Serializable; import java.security.Principal; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.ietf.jgss.GSSCredential; /** @@ -37,7 +38,7 @@ import org.ietf.jgss.GSSCredential; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class KerberosCredentials implements Credentials, Serializable { private static final long serialVersionUID = 487421613855550713L; diff --git a/httpclient/src/main/java/org/apache/http/auth/MalformedChallengeException.java b/httpclient/src/main/java/org/apache/http/auth/MalformedChallengeException.java index 172ba0c6e..2d6d14be9 100644 --- a/httpclient/src/main/java/org/apache/http/auth/MalformedChallengeException.java +++ b/httpclient/src/main/java/org/apache/http/auth/MalformedChallengeException.java @@ -27,7 +27,6 @@ package org.apache.http.auth; import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; /** * Signals that authentication challenge is in some way invalid or @@ -36,7 +35,6 @@ import org.apache.http.annotation.Immutable; * * @since 4.0 */ -@Immutable public class MalformedChallengeException extends ProtocolException { private static final long serialVersionUID = 814586927989932284L; diff --git a/httpclient/src/main/java/org/apache/http/auth/NTCredentials.java b/httpclient/src/main/java/org/apache/http/auth/NTCredentials.java index 430eb2d0b..9dd3c069f 100644 --- a/httpclient/src/main/java/org/apache/http/auth/NTCredentials.java +++ b/httpclient/src/main/java/org/apache/http/auth/NTCredentials.java @@ -30,7 +30,8 @@ import java.io.Serializable; import java.security.Principal; import java.util.Locale; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; import org.apache.http.util.LangUtils; @@ -40,7 +41,7 @@ import org.apache.http.util.LangUtils; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class NTCredentials implements Credentials, Serializable { private static final long serialVersionUID = -7385699315228907265L; diff --git a/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java b/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java index 82999395e..da0b41fa8 100644 --- a/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java +++ b/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java @@ -30,7 +30,8 @@ import java.io.Serializable; import java.security.Principal; import java.util.Locale; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; import org.apache.http.util.LangUtils; @@ -39,7 +40,7 @@ import org.apache.http.util.LangUtils; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class NTUserPrincipal implements Principal, Serializable { private static final long serialVersionUID = -6870169797924406894L; diff --git a/httpclient/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java b/httpclient/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java index b593b2472..410a95c53 100644 --- a/httpclient/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java +++ b/httpclient/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java @@ -29,7 +29,8 @@ package org.apache.http.auth; import java.io.Serializable; import java.security.Principal; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; import org.apache.http.util.LangUtils; @@ -39,7 +40,7 @@ import org.apache.http.util.LangUtils; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class UsernamePasswordCredentials implements Credentials, Serializable { private static final long serialVersionUID = 243343858802739403L; 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 489aa72e0..e04e57834 100644 --- a/httpclient/src/main/java/org/apache/http/client/CircularRedirectException.java +++ b/httpclient/src/main/java/org/apache/http/client/CircularRedirectException.java @@ -26,15 +26,12 @@ */ package org.apache.http.client; -import org.apache.http.annotation.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 8383eac47..b4efeab29 100644 --- a/httpclient/src/main/java/org/apache/http/client/ClientProtocolException.java +++ b/httpclient/src/main/java/org/apache/http/client/ClientProtocolException.java @@ -28,14 +28,11 @@ package org.apache.http.client; import java.io.IOException; -import org.apache.http.annotation.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 07e43776a..38a8cb52d 100644 --- a/httpclient/src/main/java/org/apache/http/client/HttpResponseException.java +++ b/httpclient/src/main/java/org/apache/http/client/HttpResponseException.java @@ -26,14 +26,11 @@ */ package org.apache.http.client; -import org.apache.http.annotation.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 4f4befb2c..ee70c21ad 100644 --- a/httpclient/src/main/java/org/apache/http/client/NonRepeatableRequestException.java +++ b/httpclient/src/main/java/org/apache/http/client/NonRepeatableRequestException.java @@ -27,7 +27,6 @@ package org.apache.http.client; import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; /** * Signals failure to retry the request due to non-repeatable request @@ -36,7 +35,6 @@ import org.apache.http.annotation.Immutable; * * @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 cf2abacd0..6bfa88b1b 100644 --- a/httpclient/src/main/java/org/apache/http/client/RedirectException.java +++ b/httpclient/src/main/java/org/apache/http/client/RedirectException.java @@ -27,7 +27,6 @@ package org.apache.http.client; import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; /** * Signals violation of HTTP specification caused by an invalid redirect @@ -35,7 +34,6 @@ import org.apache.http.annotation.Immutable; * * @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/config/AuthSchemes.java b/httpclient/src/main/java/org/apache/http/client/config/AuthSchemes.java index 58f5d613e..da7e26881 100644 --- a/httpclient/src/main/java/org/apache/http/client/config/AuthSchemes.java +++ b/httpclient/src/main/java/org/apache/http/client/config/AuthSchemes.java @@ -27,14 +27,11 @@ package org.apache.http.client.config; -import org.apache.http.annotation.Immutable; - /** * Standard authentication schemes supported by HttpClient. * * @since 4.3 */ -@Immutable public final class AuthSchemes { /** diff --git a/httpclient/src/main/java/org/apache/http/client/config/CookieSpecs.java b/httpclient/src/main/java/org/apache/http/client/config/CookieSpecs.java index 86477f266..3bb76a030 100644 --- a/httpclient/src/main/java/org/apache/http/client/config/CookieSpecs.java +++ b/httpclient/src/main/java/org/apache/http/client/config/CookieSpecs.java @@ -27,14 +27,11 @@ package org.apache.http.client.config; -import org.apache.http.annotation.Immutable; - /** * Standard cookie specifications supported by HttpClient. * * @since 4.3 */ -@Immutable public final class CookieSpecs { /** diff --git a/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java b/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java index 87f772ff6..38a0c732c 100644 --- a/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java +++ b/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java @@ -31,14 +31,15 @@ import java.net.InetAddress; import java.util.Collection; import org.apache.http.HttpHost; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * Immutable class encapsulating request configuration items. * The default setting for stale connection checking changed * to false, and the feature was deprecated starting with version 4.4. */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RequestConfig implements Cloneable { public static final RequestConfig DEFAULT = new Builder().build(); diff --git a/httpclient/src/main/java/org/apache/http/client/entity/EntityBuilder.java b/httpclient/src/main/java/org/apache/http/client/entity/EntityBuilder.java index ce3dfe2fe..3c966785c 100644 --- a/httpclient/src/main/java/org/apache/http/client/entity/EntityBuilder.java +++ b/httpclient/src/main/java/org/apache/http/client/entity/EntityBuilder.java @@ -35,7 +35,6 @@ import java.util.List; import org.apache.http.HttpEntity; import org.apache.http.NameValuePair; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.entity.AbstractHttpEntity; import org.apache.http.entity.BasicHttpEntity; import org.apache.http.entity.ByteArrayEntity; @@ -63,7 +62,6 @@ import org.apache.http.entity.StringEntity; * * @since 4.3 */ -@NotThreadSafe public class EntityBuilder { private String text; diff --git a/httpclient/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java b/httpclient/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java index db95ce8b4..36b285c06 100644 --- a/httpclient/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java +++ b/httpclient/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java @@ -29,12 +29,9 @@ package org.apache.http.client.entity; import java.io.IOException; import java.io.InputStream; -import org.apache.http.annotation.NotThreadSafe; - /** * Lazy init InputStream wrapper. */ -@NotThreadSafe class LazyDecompressingInputStream extends InputStream { private final InputStream wrappedStream; diff --git a/httpclient/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java b/httpclient/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java index 80bf86364..29b5be144 100644 --- a/httpclient/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java +++ b/httpclient/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java @@ -31,7 +31,6 @@ import java.nio.charset.Charset; import java.util.List; import org.apache.http.NameValuePair; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.client.utils.URLEncodedUtils; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; @@ -43,7 +42,6 @@ import org.apache.http.protocol.HTTP; * * @since 4.0 */ -@NotThreadSafe // AbstractHttpEntity is not thread-safe public class UrlEncodedFormEntity extends StringEntity { /** diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpDelete.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpDelete.java index 9b078a3ea..58d07c03d 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/HttpDelete.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpDelete.java @@ -29,8 +29,6 @@ package org.apache.http.client.methods; import java.net.URI; -import org.apache.http.annotation.NotThreadSafe; - /** * HTTP DELETE method *

@@ -46,7 +44,6 @@ import org.apache.http.annotation.NotThreadSafe; * * @since 4.0 */ -@NotThreadSafe // HttpRequestBase is @NotThreadSafe public class HttpDelete extends HttpRequestBase { public final static String METHOD_NAME = "DELETE"; diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java index 5efb82810..4fdf006c6 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java @@ -30,7 +30,6 @@ package org.apache.http.client.methods; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.client.utils.CloneUtils; import org.apache.http.protocol.HTTP; @@ -40,7 +39,6 @@ import org.apache.http.protocol.HTTP; * * @since 4.0 */ -@NotThreadSafe // HttpRequestBase is @NotThreadSafe public abstract class HttpEntityEnclosingRequestBase extends HttpRequestBase implements HttpEntityEnclosingRequest { diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpGet.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpGet.java index 35de2d3e4..e21539424 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/HttpGet.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpGet.java @@ -29,8 +29,6 @@ package org.apache.http.client.methods; import java.net.URI; -import org.apache.http.annotation.NotThreadSafe; - /** * HTTP GET method. *

@@ -47,7 +45,6 @@ import org.apache.http.annotation.NotThreadSafe; * * @since 4.0 */ -@NotThreadSafe public class HttpGet extends HttpRequestBase { public final static String METHOD_NAME = "GET"; diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpHead.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpHead.java index 4e4bd9667..bc17d95f4 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/HttpHead.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpHead.java @@ -29,8 +29,6 @@ package org.apache.http.client.methods; import java.net.URI; -import org.apache.http.annotation.NotThreadSafe; - /** * HTTP HEAD method. *

@@ -50,7 +48,6 @@ import org.apache.http.annotation.NotThreadSafe; * * @since 4.0 */ -@NotThreadSafe public class HttpHead extends HttpRequestBase { public final static String METHOD_NAME = "HEAD"; diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpOptions.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpOptions.java index 382eddac4..304ed4ab2 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/HttpOptions.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpOptions.java @@ -35,7 +35,6 @@ import org.apache.http.Header; import org.apache.http.HeaderElement; import org.apache.http.HeaderIterator; import org.apache.http.HttpResponse; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.util.Args; /** @@ -55,7 +54,6 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@NotThreadSafe public class HttpOptions extends HttpRequestBase { public final static String METHOD_NAME = "OPTIONS"; diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpPatch.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpPatch.java index 43153e4fd..c5bea336f 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/HttpPatch.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpPatch.java @@ -29,8 +29,6 @@ package org.apache.http.client.methods; import java.net.URI; -import org.apache.http.annotation.NotThreadSafe; - /** * HTTP PATCH method. *

@@ -50,7 +48,6 @@ import org.apache.http.annotation.NotThreadSafe; * * @since 4.2 */ -@NotThreadSafe public class HttpPatch extends HttpEntityEnclosingRequestBase { public final static String METHOD_NAME = "PATCH"; diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpPost.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpPost.java index 410092e0d..8a44bcae3 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/HttpPost.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpPost.java @@ -29,8 +29,6 @@ package org.apache.http.client.methods; import java.net.URI; -import org.apache.http.annotation.NotThreadSafe; - /** * HTTP POST method. *

@@ -54,7 +52,6 @@ import org.apache.http.annotation.NotThreadSafe; * * @since 4.0 */ -@NotThreadSafe public class HttpPost extends HttpEntityEnclosingRequestBase { public final static String METHOD_NAME = "POST"; diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpPut.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpPut.java index ac0515a64..59c4ca2e4 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/HttpPut.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpPut.java @@ -29,8 +29,6 @@ package org.apache.http.client.methods; import java.net.URI; -import org.apache.http.annotation.NotThreadSafe; - /** * HTTP PUT method. *

@@ -46,7 +44,6 @@ import org.apache.http.annotation.NotThreadSafe; * * @since 4.0 */ -@NotThreadSafe public class HttpPut extends HttpEntityEnclosingRequestBase { public final static String METHOD_NAME = "PUT"; diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestBase.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestBase.java index f997c3ca7..e5c47d41c 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestBase.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestBase.java @@ -31,7 +31,6 @@ import java.net.URI; import org.apache.http.ProtocolVersion; import org.apache.http.RequestLine; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.client.config.RequestConfig; import org.apache.http.message.BasicRequestLine; import org.apache.http.params.HttpProtocolParams; @@ -42,7 +41,6 @@ import org.apache.http.params.HttpProtocolParams; * @since 4.0 */ @SuppressWarnings("deprecation") -@NotThreadSafe public abstract class HttpRequestBase extends AbstractExecutionAwareRequest implements HttpUriRequest, Configurable { diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java index 3df8bbb5b..dbfbd0e14 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java @@ -36,7 +36,6 @@ import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.ProtocolVersion; import org.apache.http.RequestLine; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.message.AbstractHttpMessage; import org.apache.http.message.BasicRequestLine; import org.apache.http.params.HttpParams; @@ -50,7 +49,6 @@ import org.apache.http.util.Args; * @since 4.3 */ @SuppressWarnings("deprecation") -@NotThreadSafe public class HttpRequestWrapper extends AbstractHttpMessage implements HttpUriRequest { private final HttpRequest original; diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpTrace.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpTrace.java index c0bcc8616..51b373848 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/HttpTrace.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpTrace.java @@ -29,8 +29,6 @@ package org.apache.http.client.methods; import java.net.URI; -import org.apache.http.annotation.NotThreadSafe; - /** * HTTP TRACE method. *

@@ -49,7 +47,6 @@ import org.apache.http.annotation.NotThreadSafe; * * @since 4.0 */ -@NotThreadSafe public class HttpTrace extends HttpRequestBase { public final static String METHOD_NAME = "TRACE"; diff --git a/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java b/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java index f6cd6816b..b630dba94 100644 --- a/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java +++ b/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java @@ -43,7 +43,6 @@ import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpRequest; import org.apache.http.NameValuePair; import org.apache.http.ProtocolVersion; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.utils.URIBuilder; @@ -67,7 +66,6 @@ import org.apache.http.util.Args; * * @since 4.3 */ -@NotThreadSafe public class RequestBuilder { private String method; diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.java b/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.java index db363c492..e763e9a70 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.java @@ -30,7 +30,6 @@ package org.apache.http.client.protocol; import java.net.URI; import java.util.List; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.AuthSchemeProvider; import org.apache.http.auth.AuthState; import org.apache.http.client.AuthCache; @@ -54,7 +53,6 @@ import org.apache.http.protocol.HttpCoreContext; * * @since 4.3 */ -@NotThreadSafe public class HttpClientContext extends HttpCoreContext { /** diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/RequestAcceptEncoding.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAcceptEncoding.java index 9b260e206..74749facf 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestAcceptEncoding.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAcceptEncoding.java @@ -32,7 +32,8 @@ import java.util.List; import org.apache.http.HttpException; import org.apache.http.HttpRequest; import org.apache.http.HttpRequestInterceptor; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.config.RequestConfig; import org.apache.http.protocol.HttpContext; @@ -45,7 +46,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RequestAcceptEncoding implements HttpRequestInterceptor { private final String acceptEncoding; 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 b548d043f..02656be6d 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 @@ -41,7 +41,8 @@ import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpRequestInterceptor; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.CookieStore; import org.apache.http.client.config.CookieSpecs; import org.apache.http.client.config.RequestConfig; @@ -63,7 +64,7 @@ import org.apache.http.util.TextUtils; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.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/RequestAuthCache.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java index fa6a36299..aa3007356 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java @@ -35,7 +35,8 @@ import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpRequestInterceptor; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthProtocolState; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthScope; @@ -54,7 +55,7 @@ import org.apache.http.util.Args; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RequestAuthCache implements HttpRequestInterceptor { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/RequestClientConnControl.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestClientConnControl.java index aba6602c9..36049da41 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestClientConnControl.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestClientConnControl.java @@ -34,7 +34,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.http.HttpException; import org.apache.http.HttpRequest; import org.apache.http.HttpRequestInterceptor; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.routing.RouteInfo; import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HttpContext; @@ -47,7 +48,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RequestClientConnControl 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 967270a1c..1fd556ffe 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,7 +34,8 @@ import org.apache.http.Header; import org.apache.http.HttpException; import org.apache.http.HttpRequest; import org.apache.http.HttpRequestInterceptor; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.params.ClientPNames; import org.apache.http.protocol.HttpContext; import org.apache.http.util.Args; @@ -45,7 +46,7 @@ import org.apache.http.util.Args; * @since 4.0 */ @SuppressWarnings("deprecation") -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class RequestDefaultHeaders implements HttpRequestInterceptor { private final Collection defaultHeaders; diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/RequestExpectContinue.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestExpectContinue.java index 27edc1784..e958a7a44 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestExpectContinue.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestExpectContinue.java @@ -36,7 +36,8 @@ import org.apache.http.HttpRequest; import org.apache.http.HttpRequestInterceptor; import org.apache.http.HttpVersion; import org.apache.http.ProtocolVersion; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.config.RequestConfig; import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HttpContext; @@ -52,7 +53,7 @@ import org.apache.http.util.Args; * * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RequestExpectContinue implements HttpRequestInterceptor { public RequestExpectContinue() { diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java b/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java index c4d0cfc9f..8bb63c657 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java @@ -37,7 +37,8 @@ import org.apache.http.HttpEntity; import org.apache.http.HttpException; import org.apache.http.HttpResponse; import org.apache.http.HttpResponseInterceptor; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.entity.DecompressingEntity; import org.apache.http.client.entity.DeflateInputStream; @@ -55,7 +56,7 @@ import org.apache.http.protocol.HttpContext; * @since 4.1 * */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class ResponseContentEncoding implements HttpResponseInterceptor { public static final String UNCOMPRESSED = "http.client.response.uncompressed"; 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 5f3cfaba0..293721e0d 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 @@ -37,7 +37,8 @@ import org.apache.http.HeaderIterator; import org.apache.http.HttpException; import org.apache.http.HttpResponse; import org.apache.http.HttpResponseInterceptor; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.CookieStore; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieOrigin; @@ -53,7 +54,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.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 597dc2668..be8e56d7c 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 @@ -29,14 +29,11 @@ package org.apache.http.client.utils; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import org.apache.http.annotation.Immutable; - /** * A collection of utilities to workaround limitations of Java clone framework. * * @since 4.0 */ -@Immutable public class CloneUtils { /** diff --git a/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java index a18fbd724..2de83fe2e 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java @@ -37,7 +37,6 @@ import java.util.Locale; import java.util.Map; import java.util.TimeZone; -import org.apache.http.annotation.Immutable; import org.apache.http.util.Args; /** @@ -47,7 +46,6 @@ import org.apache.http.util.Args; * * @since 4.3 */ -@Immutable public final class DateUtils { /** diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java b/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java index 227e494a1..1cc54ebce 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java @@ -35,7 +35,6 @@ import java.util.List; import org.apache.http.Consts; import org.apache.http.NameValuePair; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.conn.util.InetAddressUtils; import org.apache.http.message.BasicNameValuePair; @@ -44,7 +43,6 @@ import org.apache.http.message.BasicNameValuePair; * * @since 4.2 */ -@NotThreadSafe public class URIBuilder { private String scheme; 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 72c299ef9..02f8c1ae9 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,7 +33,6 @@ import java.util.Locale; import java.util.Stack; import org.apache.http.HttpHost; -import org.apache.http.annotation.Immutable; import org.apache.http.conn.routing.RouteInfo; import org.apache.http.util.Args; import org.apache.http.util.TextUtils; @@ -44,7 +43,6 @@ import org.apache.http.util.TextUtils; * * @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 adc81c715..8547cf0b4 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 @@ -46,7 +46,6 @@ import org.apache.http.Header; import org.apache.http.HeaderElement; import org.apache.http.HttpEntity; import org.apache.http.NameValuePair; -import org.apache.http.annotation.Immutable; import org.apache.http.entity.ContentType; import org.apache.http.message.BasicNameValuePair; import org.apache.http.message.ParserCursor; @@ -60,7 +59,6 @@ import org.apache.http.util.CharArrayBuffer; * * @since 4.0 */ -@Immutable public class URLEncodedUtils { /** 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 a76bcdadb..ed2b3297b 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ConnectTimeoutException.java +++ b/httpclient/src/main/java/org/apache/http/conn/ConnectTimeoutException.java @@ -33,7 +33,6 @@ import java.net.InetAddress; import java.util.Arrays; import org.apache.http.HttpHost; -import org.apache.http.annotation.Immutable; /** * A timeout while connecting to an HTTP server or waiting for an @@ -42,7 +41,6 @@ import org.apache.http.annotation.Immutable; * * @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 3328cc41e..cd75078a7 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ConnectionPoolTimeoutException.java +++ b/httpclient/src/main/java/org/apache/http/conn/ConnectionPoolTimeoutException.java @@ -27,8 +27,6 @@ package org.apache.http.conn; -import org.apache.http.annotation.Immutable; - /** * A timeout while waiting for an available connection * from a connection manager. @@ -36,7 +34,6 @@ import org.apache.http.annotation.Immutable; * * @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/EofSensorInputStream.java b/httpclient/src/main/java/org/apache/http/conn/EofSensorInputStream.java index 50486311f..fb7de2d6b 100644 --- a/httpclient/src/main/java/org/apache/http/conn/EofSensorInputStream.java +++ b/httpclient/src/main/java/org/apache/http/conn/EofSensorInputStream.java @@ -29,7 +29,6 @@ package org.apache.http.conn; import java.io.IOException; import java.io.InputStream; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.util.Args; /** @@ -43,7 +42,6 @@ import org.apache.http.util.Args; */ // don't use FilterInputStream as the base class, we'd have to // override markSupported(), mark(), and reset() to disable them -@NotThreadSafe public class EofSensorInputStream extends InputStream implements ConnectionReleaseTrigger { /** 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 fa88a45cf..7a0261664 100644 --- a/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java +++ b/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java @@ -32,7 +32,6 @@ import java.net.InetAddress; import java.util.Arrays; import org.apache.http.HttpHost; -import org.apache.http.annotation.Immutable; /** * A {@link ConnectException} that specifies the {@link HttpHost} that was @@ -40,7 +39,6 @@ import org.apache.http.annotation.Immutable; * * @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/UnsupportedSchemeException.java b/httpclient/src/main/java/org/apache/http/conn/UnsupportedSchemeException.java index 268a0b80a..69c66d96d 100644 --- a/httpclient/src/main/java/org/apache/http/conn/UnsupportedSchemeException.java +++ b/httpclient/src/main/java/org/apache/http/conn/UnsupportedSchemeException.java @@ -29,14 +29,11 @@ package org.apache.http.conn; import java.io.IOException; -import org.apache.http.annotation.Immutable; - /** * Signals failure to establish connection using an unknown protocol scheme. * * @since 4.3 */ -@Immutable public class UnsupportedSchemeException extends IOException { private static final long serialVersionUID = 3597127619218687636L; diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java b/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java index eff3f04a2..09764b474 100644 --- a/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java +++ b/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java @@ -27,7 +27,8 @@ package org.apache.http.conn.routing; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; /** @@ -35,7 +36,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class BasicRouteDirector implements HttpRouteDirector { /** 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 847fa7e8f..60a02e726 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 @@ -35,7 +35,8 @@ import java.util.Collections; import java.util.List; import org.apache.http.HttpHost; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; import org.apache.http.util.LangUtils; @@ -44,7 +45,7 @@ import org.apache.http.util.LangUtils; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public final class HttpRoute implements RouteInfo, Cloneable { /** The target host to connect to. */ diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java b/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java index e55079970..b58aca67d 100644 --- a/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java +++ b/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java @@ -30,7 +30,6 @@ package org.apache.http.conn.routing; import java.net.InetAddress; import org.apache.http.HttpHost; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.util.Args; import org.apache.http.util.Asserts; import org.apache.http.util.LangUtils; @@ -40,7 +39,6 @@ import org.apache.http.util.LangUtils; * * @since 4.0 */ -@NotThreadSafe public final class RouteTracker implements RouteInfo, Cloneable { /** The target host to connect to. */ 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 68d7aa98e..6d02b95fe 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 @@ -28,7 +28,8 @@ package org.apache.http.conn.scheme; import java.util.Locale; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; import org.apache.http.util.LangUtils; @@ -50,7 +51,7 @@ import org.apache.http.util.LangUtils; * @deprecated (4.3) use {@link org.apache.http.conn.SchemePortResolver} for default port * resolution and {@link org.apache.http.config.Registry} for socket factory lookups. */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public final class Scheme { 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 6928ce562..d05f232e8 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 @@ -32,7 +32,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.http.HttpHost; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; /** @@ -43,7 +44,7 @@ import org.apache.http.util.Args; * * @deprecated (4.3) use {@link org.apache.http.config.Registry} */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) @Deprecated public final class SchemeRegistry { diff --git a/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java index 193e73da0..3ec167c66 100644 --- a/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java +++ b/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java @@ -32,7 +32,8 @@ import java.net.InetSocketAddress; import java.net.Socket; import org.apache.http.HttpHost; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.protocol.HttpContext; /** @@ -40,7 +41,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class PlainConnectionSocketFactory implements ConnectionSocketFactory { public static final PlainConnectionSocketFactory INSTANCE = new PlainConnectionSocketFactory(); 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 3dc856ed7..29d776356 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 @@ -27,7 +27,8 @@ package org.apache.http.conn.ssl; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * The ALLOW_ALL HostnameVerifier essentially turns hostname verification @@ -39,7 +40,7 @@ import org.apache.http.annotation.Immutable; * @deprecated (4.4) Use {@link org.apache.http.conn.ssl.NoopHostnameVerifier} */ @Deprecated -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class AllowAllHostnameVerifier extends AbstractVerifier { public static final AllowAllHostnameVerifier INSTANCE = new AllowAllHostnameVerifier(); 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 4c4aee9a0..9fd886745 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 @@ -29,7 +29,8 @@ package org.apache.http.conn.ssl; import javax.net.ssl.SSLException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * The HostnameVerifier that works the same way as Curl and Firefox. @@ -47,7 +48,7 @@ import org.apache.http.annotation.Immutable; * * @deprecated (4.4) Use {@link org.apache.http.conn.ssl.DefaultHostnameVerifier} */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class BrowserCompatHostnameVerifier extends AbstractVerifier { diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java b/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java index 299e7a766..64b63f731 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java +++ b/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java @@ -51,7 +51,8 @@ import javax.security.auth.x500.X500Principal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.util.DomainType; import org.apache.http.conn.util.InetAddressUtils; import org.apache.http.conn.util.PublicSuffixMatcher; @@ -61,7 +62,7 @@ import org.apache.http.conn.util.PublicSuffixMatcher; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public final class DefaultHostnameVerifier implements HostnameVerifier { enum TYPE { IPv4, IPv6, DNS } diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/NoopHostnameVerifier.java b/httpclient/src/main/java/org/apache/http/conn/ssl/NoopHostnameVerifier.java index 1b5cdd954..40ceb8a25 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ssl/NoopHostnameVerifier.java +++ b/httpclient/src/main/java/org/apache/http/conn/ssl/NoopHostnameVerifier.java @@ -30,7 +30,8 @@ package org.apache.http.conn.ssl; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLSession; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * The NO_OP HostnameVerifier essentially turns hostname verification @@ -38,7 +39,7 @@ import org.apache.http.annotation.Immutable; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class NoopHostnameVerifier implements HostnameVerifier { public static final NoopHostnameVerifier INSTANCE = new NoopHostnameVerifier(); diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java index df8689b42..504f24ada 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java +++ b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java @@ -50,7 +50,8 @@ import javax.security.auth.x500.X500Principal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpHost; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.socket.LayeredConnectionSocketFactory; import org.apache.http.conn.util.PublicSuffixMatcherLoader; import org.apache.http.protocol.HttpContext; @@ -133,7 +134,8 @@ import org.apache.http.util.TextUtils; * * @since 4.3 */ -@ThreadSafe @SuppressWarnings("deprecation") +@Contract(threading = ThreadingBehavior.SAFE) +@SuppressWarnings("deprecation") public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactory { public static final String TLS = "TLS"; 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 362d6abe9..eb1c05750 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 @@ -29,7 +29,8 @@ package org.apache.http.conn.ssl; import javax.net.ssl.SSLException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * The Strict HostnameVerifier works the same way as Sun Java 1.4, Sun @@ -53,7 +54,7 @@ import org.apache.http.annotation.Immutable; * * @deprecated (4.4) Use {@link org.apache.http.conn.ssl.DefaultHostnameVerifier} */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @Deprecated public class StrictHostnameVerifier extends AbstractVerifier { 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 acee8afa2..8715200aa 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 @@ -29,14 +29,11 @@ package org.apache.http.conn.util; import java.util.regex.Pattern; -import org.apache.http.annotation.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/conn/util/PublicSuffixList.java b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixList.java index dfdd928ce..273c5ca32 100644 --- a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixList.java +++ b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixList.java @@ -29,7 +29,8 @@ package org.apache.http.conn.util; import java.util.Collections; import java.util.List; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; /** @@ -41,7 +42,7 @@ import org.apache.http.util.Args; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public final class PublicSuffixList { private final DomainType type; diff --git a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixListParser.java b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixListParser.java index 0bf63e18e..d13210fa2 100644 --- a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixListParser.java +++ b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixListParser.java @@ -32,7 +32,8 @@ import java.io.Reader; import java.util.ArrayList; import java.util.List; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * Parses the list from publicsuffix.org @@ -40,7 +41,7 @@ import org.apache.http.annotation.Immutable; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public final class PublicSuffixListParser { public PublicSuffixListParser() { diff --git a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java index 2ec340f61..ce2a2c901 100644 --- a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java +++ b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java @@ -33,7 +33,8 @@ import java.util.Locale; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; /** @@ -46,7 +47,7 @@ import org.apache.http.util.Args; * * @since 4.4 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public final class PublicSuffixMatcher { private final Map rules; diff --git a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcherLoader.java b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcherLoader.java index 5a25b4610..8783c5b96 100644 --- a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcherLoader.java +++ b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcherLoader.java @@ -38,7 +38,8 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.Consts; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; /** @@ -46,7 +47,7 @@ import org.apache.http.util.Args; * * @since 4.4 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public final class PublicSuffixMatcherLoader { private static PublicSuffixMatcher load(final InputStream in) throws IOException { 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 935a5a338..d5a11e129 100644 --- a/httpclient/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java +++ b/httpclient/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java @@ -30,7 +30,8 @@ package org.apache.http.cookie; import java.io.Serializable; import java.util.Comparator; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * This cookie comparator can be used to compare identity of cookies. @@ -40,7 +41,7 @@ import org.apache.http.annotation.Immutable; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.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 b46f6bd35..d856258f3 100644 --- a/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java +++ b/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java @@ -28,7 +28,8 @@ package org.apache.http.cookie; import java.util.Locale; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; import org.apache.http.util.TextUtils; @@ -38,7 +39,7 @@ import org.apache.http.util.TextUtils; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.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 f9e3e7672..c8fe21cd6 100644 --- a/httpclient/src/main/java/org/apache/http/cookie/CookiePathComparator.java +++ b/httpclient/src/main/java/org/apache/http/cookie/CookiePathComparator.java @@ -30,7 +30,8 @@ package org.apache.http.cookie; import java.io.Serializable; import java.util.Comparator; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * This cookie comparator ensures that multiple cookies satisfying @@ -47,7 +48,7 @@ import org.apache.http.annotation.Immutable; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class CookiePathComparator implements Serializable, Comparator { public static final CookiePathComparator INSTANCE = new CookiePathComparator(); diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookiePriorityComparator.java b/httpclient/src/main/java/org/apache/http/cookie/CookiePriorityComparator.java index 77e4e0132..ab0932df5 100644 --- a/httpclient/src/main/java/org/apache/http/cookie/CookiePriorityComparator.java +++ b/httpclient/src/main/java/org/apache/http/cookie/CookiePriorityComparator.java @@ -30,7 +30,8 @@ package org.apache.http.cookie; import java.util.Comparator; import java.util.Date; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.impl.cookie.BasicClientCookie; /** @@ -40,7 +41,7 @@ import org.apache.http.impl.cookie.BasicClientCookie; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class CookiePriorityComparator implements Comparator { public static final CookiePriorityComparator INSTANCE = new CookiePriorityComparator(); diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookieRestrictionViolationException.java b/httpclient/src/main/java/org/apache/http/cookie/CookieRestrictionViolationException.java index 3b30a977b..b1a482e89 100644 --- a/httpclient/src/main/java/org/apache/http/cookie/CookieRestrictionViolationException.java +++ b/httpclient/src/main/java/org/apache/http/cookie/CookieRestrictionViolationException.java @@ -27,15 +27,12 @@ package org.apache.http.cookie; -import org.apache.http.annotation.Immutable; - /** * Signals that a cookie violates a restriction imposed by the cookie * specification. * * @since 4.1 */ -@Immutable public class CookieRestrictionViolationException extends MalformedCookieException { private static final long serialVersionUID = 7371235577078589013L; 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 43e6ffeb6..e24be611f 100644 --- a/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java +++ b/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java @@ -34,7 +34,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.http.HttpRequest; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.config.Lookup; import org.apache.http.params.HttpParams; import org.apache.http.protocol.ExecutionContext; @@ -50,7 +51,7 @@ import org.apache.http.util.Args; * * @deprecated (4.3) use {@link org.apache.http.config.Registry}. */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) @Deprecated public final class CookieSpecRegistry implements Lookup { 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 da70979c6..4c881a913 100644 --- a/httpclient/src/main/java/org/apache/http/cookie/MalformedCookieException.java +++ b/httpclient/src/main/java/org/apache/http/cookie/MalformedCookieException.java @@ -28,7 +28,6 @@ package org.apache.http.cookie; import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; /** * Signals that a cookie is in some way invalid or illegal in a given @@ -37,7 +36,6 @@ import org.apache.http.annotation.Immutable; * * @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/AuthSchemeBase.java b/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java index 452516a88..296b15c34 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java @@ -31,7 +31,6 @@ import java.util.Locale; import org.apache.http.FormattedHeader; import org.apache.http.Header; import org.apache.http.HttpRequest; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.ChallengeState; @@ -53,7 +52,6 @@ import org.apache.http.util.CharArrayBuffer; * * @since 4.0 */ -@NotThreadSafe public abstract class AuthSchemeBase implements ContextAwareAuthScheme { protected ChallengeState challengeState; diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java index 2f51de703..cfd5a6e05 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java @@ -32,7 +32,6 @@ import org.apache.commons.codec.binary.Base64; import org.apache.http.Consts; import org.apache.http.Header; import org.apache.http.HttpRequest; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.ChallengeState; @@ -50,7 +49,6 @@ import org.apache.http.util.EncodingUtils; * * @since 4.0 */ -@NotThreadSafe public class BasicScheme extends RFC2617Scheme { private static final long serialVersionUID = -1931571557597830536L; 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 5409a771f..69402d241 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 @@ -29,7 +29,8 @@ package org.apache.http.impl.auth; import java.nio.charset.Charset; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthSchemeFactory; import org.apache.http.auth.AuthSchemeProvider; @@ -42,7 +43,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @SuppressWarnings("deprecation") public class BasicSchemeFactory implements AuthSchemeFactory, AuthSchemeProvider { diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java index a7607e330..1e3c62f41 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java @@ -43,7 +43,6 @@ import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpRequest; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.ChallengeState; @@ -72,7 +71,6 @@ import org.apache.http.util.EncodingUtils; * * @since 4.0 */ -@NotThreadSafe public class DigestScheme extends RFC2617Scheme { private static final long serialVersionUID = 3883908186234566916L; 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 67a4e9edb..3cc979613 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 @@ -29,7 +29,8 @@ package org.apache.http.impl.auth; import java.nio.charset.Charset; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthSchemeFactory; import org.apache.http.auth.AuthSchemeProvider; @@ -42,7 +43,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @SuppressWarnings("deprecation") public class DigestSchemeFactory implements AuthSchemeFactory, AuthSchemeProvider { diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java b/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java index d9e008f40..1fbc86a14 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java @@ -35,7 +35,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.http.Header; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.Credentials; @@ -58,7 +57,6 @@ import org.ietf.jgss.Oid; /** * @since 4.2 */ -@NotThreadSafe public abstract class GGSSchemeBase extends AuthSchemeBase { enum State { diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java index 9b2ba6206..6cbb05bb9 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java @@ -28,7 +28,6 @@ package org.apache.http.impl.auth; import org.apache.http.Header; import org.apache.http.HttpRequest; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.Credentials; import org.apache.http.protocol.HttpContext; @@ -41,7 +40,6 @@ import org.ietf.jgss.Oid; * * @since 4.2 */ -@NotThreadSafe public class KerberosScheme extends GGSSchemeBase { private static final String KERBEROS_OID = "1.2.840.113554.1.2.2"; diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/KerberosSchemeFactory.java b/httpclient/src/main/java/org/apache/http/impl/auth/KerberosSchemeFactory.java index 431258e96..7096e6982 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/KerberosSchemeFactory.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/KerberosSchemeFactory.java @@ -26,7 +26,8 @@ */ package org.apache.http.impl.auth; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthSchemeFactory; import org.apache.http.auth.AuthSchemeProvider; @@ -39,7 +40,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.2 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @SuppressWarnings("deprecation") public class KerberosSchemeFactory implements AuthSchemeFactory, AuthSchemeProvider { 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 f902ae1bc..04180c0df 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 @@ -26,7 +26,6 @@ */ package org.apache.http.impl.auth; -import org.apache.http.annotation.Immutable; import org.apache.http.auth.AuthenticationException; /** @@ -35,7 +34,6 @@ 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/NTLMEngineImpl.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java index 890f6474c..1a7dc8b57 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java @@ -38,7 +38,6 @@ import javax.crypto.spec.SecretKeySpec; import org.apache.commons.codec.binary.Base64; import org.apache.http.Consts; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.util.CharsetUtils; import org.apache.http.util.EncodingUtils; @@ -48,7 +47,6 @@ import org.apache.http.util.EncodingUtils; * * @since 4.1 */ -@NotThreadSafe final class NTLMEngineImpl implements NTLMEngine { /** Unicode encoding */ diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java index 1ec4957d4..cd1a2127f 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java @@ -28,7 +28,6 @@ package org.apache.http.impl.auth; import org.apache.http.Header; import org.apache.http.HttpRequest; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.Credentials; @@ -45,7 +44,6 @@ import org.apache.http.util.CharArrayBuffer; * * @since 4.0 */ -@NotThreadSafe public class NTLMScheme extends AuthSchemeBase { enum State { diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMSchemeFactory.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMSchemeFactory.java index 8e38c82ae..869f6667e 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMSchemeFactory.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMSchemeFactory.java @@ -27,7 +27,8 @@ package org.apache.http.impl.auth; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthSchemeFactory; import org.apache.http.auth.AuthSchemeProvider; @@ -41,7 +42,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @SuppressWarnings("deprecation") public class NTLMSchemeFactory implements AuthSchemeFactory, AuthSchemeProvider { diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java index 9475c03a4..d7b6852d2 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java @@ -39,7 +39,6 @@ import java.util.Map; import org.apache.http.Consts; import org.apache.http.HeaderElement; import org.apache.http.HttpRequest; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.ChallengeState; import org.apache.http.auth.MalformedChallengeException; import org.apache.http.auth.params.AuthPNames; @@ -57,7 +56,6 @@ import org.apache.http.util.CharsetUtils; * @since 4.0 */ @SuppressWarnings("deprecation") -@NotThreadSafe // AuthSchemeBase, params public abstract class RFC2617Scheme extends AuthSchemeBase implements Serializable { private static final long serialVersionUID = -2845454858205884623L; diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java index 808738b44..46ebeb862 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java @@ -28,7 +28,6 @@ package org.apache.http.impl.auth; import org.apache.http.Header; import org.apache.http.HttpRequest; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.Credentials; import org.apache.http.protocol.HttpContext; @@ -42,7 +41,6 @@ import org.ietf.jgss.Oid; * * @since 4.2 */ -@NotThreadSafe public class SPNegoScheme extends GGSSchemeBase { private static final String SPNEGO_OID = "1.3.6.1.5.5.2"; diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoSchemeFactory.java b/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoSchemeFactory.java index 42e506dfd..fa09a2b58 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoSchemeFactory.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoSchemeFactory.java @@ -26,7 +26,8 @@ */ package org.apache.http.impl.auth; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthSchemeFactory; import org.apache.http.auth.AuthSchemeProvider; @@ -39,7 +40,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.2 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) @SuppressWarnings("deprecation") public class SPNegoSchemeFactory implements AuthSchemeFactory, AuthSchemeProvider { 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 2d6b6ec84..0465af515 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 @@ -26,8 +26,6 @@ */ package org.apache.http.impl.auth; -import org.apache.http.annotation.Immutable; - /** * Authentication credentials required to respond to a authentication * challenge are invalid @@ -35,7 +33,6 @@ import org.apache.http.annotation.Immutable; * * @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/AbstractResponseHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/AbstractResponseHandler.java index 290a88ce3..d87775bdd 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/AbstractResponseHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/AbstractResponseHandler.java @@ -32,7 +32,8 @@ import java.io.IOException; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.StatusLine; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.HttpResponseException; import org.apache.http.client.ResponseHandler; import org.apache.http.util.EntityUtils; @@ -50,7 +51,7 @@ import org.apache.http.util.EntityUtils; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public abstract class AbstractResponseHandler implements ResponseHandler { /** diff --git a/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java b/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java index cd15aeabb..57df6141f 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java @@ -43,7 +43,8 @@ import org.apache.http.FormattedHeader; import org.apache.http.Header; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthOption; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthSchemeProvider; @@ -62,7 +63,7 @@ import org.apache.http.protocol.HttpContext; import org.apache.http.util.Args; import org.apache.http.util.CharArrayBuffer; -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) abstract class AuthenticationStrategyImpl implements AuthenticationStrategy { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java b/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java index 97dabb3d7..4d163bae5 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java @@ -38,7 +38,8 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpHost; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScheme; import org.apache.http.client.AuthCache; import org.apache.http.conn.SchemePortResolver; @@ -56,7 +57,7 @@ import org.apache.http.util.Args; * * @since 4.1 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class BasicAuthCache implements AuthCache { private final Log log = LogFactory.getLog(getClass()); 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 52b76b1cb..d2468f633 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 @@ -33,8 +33,8 @@ import java.util.Iterator; import java.util.List; import java.util.TreeSet; -import org.apache.http.annotation.GuardedBy; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.CookieStore; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieIdentityComparator; @@ -45,12 +45,11 @@ import org.apache.http.cookie.CookieIdentityComparator; * * @since 4.0 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class BasicCookieStore implements CookieStore, Serializable { private static final long serialVersionUID = -7581093305228232025L; - @GuardedBy("this") private final TreeSet cookies; public BasicCookieStore() { 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 352bbfd54..99bab9131 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 @@ -29,7 +29,8 @@ package org.apache.http.impl.client; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScope; import org.apache.http.auth.Credentials; import org.apache.http.client.CredentialsProvider; @@ -40,7 +41,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class BasicCredentialsProvider implements CredentialsProvider { private final ConcurrentHashMap 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 76766ea7e..09fdb5252 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 @@ -31,7 +31,8 @@ import java.io.IOException; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.HttpResponseException; import org.apache.http.util.EntityUtils; @@ -48,7 +49,7 @@ import org.apache.http.util.EntityUtils; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class BasicResponseHandler extends AbstractResponseHandler { /** diff --git a/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java index 16dfae215..866d6c12a 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java @@ -36,7 +36,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.http.HttpEntity; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.ResponseHandler; @@ -52,7 +53,7 @@ import org.apache.http.util.EntityUtils; * * @since 4.3 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public abstract class CloseableHttpClient implements HttpClient, Closeable { private final Log log = LogFactory.getLog(getClass()); 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 6e757d1ee..d162db765 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 @@ -29,7 +29,8 @@ package org.apache.http.impl.client; import org.apache.http.HeaderElement; import org.apache.http.HeaderElementIterator; import org.apache.http.HttpResponse; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.ConnectionKeepAliveStrategy; import org.apache.http.message.BasicHeaderElementIterator; import org.apache.http.protocol.HTTP; @@ -45,7 +46,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveStrategy { public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy(); 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 b647cd343..dd5eb4a85 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 @@ -40,7 +40,8 @@ import javax.net.ssl.SSLException; import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpRequest; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.HttpRequestRetryHandler; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.protocol.HttpClientContext; @@ -52,7 +53,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler { public static final DefaultHttpRequestRetryHandler INSTANCE = new DefaultHttpRequestRetryHandler(); diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java index 47249ee5f..0e02b2989 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java @@ -39,7 +39,8 @@ import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.CircularRedirectException; import org.apache.http.client.RedirectStrategy; import org.apache.http.client.config.RequestConfig; @@ -70,7 +71,7 @@ import org.apache.http.util.TextUtils; * @see LaxRedirectStrategy * @since 4.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class DefaultRedirectStrategy implements RedirectStrategy { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java index f00720707..e80bc5b53 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java @@ -29,7 +29,8 @@ package org.apache.http.impl.client; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.ServiceUnavailableRetryStrategy; import org.apache.http.protocol.HttpContext; import org.apache.http.util.Args; @@ -41,7 +42,7 @@ import org.apache.http.util.Args; * * @since 4.2 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class DefaultServiceUnavailableRetryStrategy implements ServiceUnavailableRetryStrategy { /** 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 e2a43c4b8..a47f027bd 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 @@ -31,7 +31,8 @@ import java.security.Principal; import javax.net.ssl.SSLSession; import org.apache.http.HttpConnection; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthState; import org.apache.http.auth.Credentials; @@ -54,7 +55,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class DefaultUserTokenHandler implements UserTokenHandler { public static final DefaultUserTokenHandler INSTANCE = new DefaultUserTokenHandler(); diff --git a/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java b/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java index 15aedd564..061ae3f5c 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java @@ -35,7 +35,6 @@ import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.ProtocolException; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.entity.HttpEntityWrapper; import org.apache.http.protocol.HTTP; @@ -53,7 +52,6 @@ import org.apache.http.protocol.HTTP; * @deprecated (4.3) do not use. */ @Deprecated -@NotThreadSafe // e.g. [gs]etEntity() public class EntityEnclosingRequestWrapper extends RequestWrapper implements HttpEntityEnclosingRequest { diff --git a/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java b/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java index 0fcfd4dfc..89b06d499 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java @@ -31,7 +31,8 @@ import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.HttpClient; import org.apache.http.client.ResponseHandler; import org.apache.http.client.methods.HttpUriRequest; @@ -42,7 +43,7 @@ import org.apache.http.protocol.HttpContext; * HttpAsyncClientWithFuture wraps calls to execute with a {@link HttpRequestFutureTask} * and schedules them using the provided executor service. Scheduled calls may be cancelled. */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class FutureRequestExecutionService implements Closeable { private final HttpClient httpclient; diff --git a/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java b/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java index dab3ab135..507f7d390 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java @@ -47,7 +47,6 @@ import org.apache.http.Header; import org.apache.http.HttpHost; import org.apache.http.HttpRequestInterceptor; import org.apache.http.HttpResponseInterceptor; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.AuthSchemeProvider; import org.apache.http.client.AuthenticationStrategy; import org.apache.http.client.BackoffManager; @@ -153,7 +152,6 @@ import org.apache.http.util.VersionInfo; * * @since 4.3 */ -@NotThreadSafe public class HttpClientBuilder { private HttpRequestExecutor requestExec; diff --git a/httpclient/src/main/java/org/apache/http/impl/client/HttpClients.java b/httpclient/src/main/java/org/apache/http/impl/client/HttpClients.java index 569b047a6..c43b460ac 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/HttpClients.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/HttpClients.java @@ -27,7 +27,6 @@ package org.apache.http.impl.client; -import org.apache.http.annotation.Immutable; import org.apache.http.conn.HttpClientConnectionManager; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; @@ -35,7 +34,6 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; * Factory methods for {@link CloseableHttpClient} instances. * @since 4.3 */ -@Immutable public class HttpClients { private HttpClients() { diff --git a/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java index d49dfee7f..20bf06052 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java @@ -37,7 +37,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthSchemeProvider; import org.apache.http.auth.AuthState; import org.apache.http.client.ClientProtocolException; @@ -72,7 +73,7 @@ import org.apache.http.util.Args; * * @since 4.3 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) @SuppressWarnings("deprecation") class InternalHttpClient extends CloseableHttpClient implements Configurable { diff --git a/httpclient/src/main/java/org/apache/http/impl/client/LaxRedirectStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/LaxRedirectStrategy.java index 8e7ba7e24..fed513ac6 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/LaxRedirectStrategy.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/LaxRedirectStrategy.java @@ -27,7 +27,8 @@ package org.apache.http.impl.client; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpHead; @@ -41,7 +42,7 @@ import org.apache.http.client.methods.HttpPost; * * @since 4.2 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class LaxRedirectStrategy extends DefaultRedirectStrategy { public static final LaxRedirectStrategy INSTANCE = new LaxRedirectStrategy(); diff --git a/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java index 6d1ead7ec..30ce49271 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java @@ -33,7 +33,8 @@ import java.util.concurrent.TimeUnit; import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; @@ -61,7 +62,7 @@ import org.apache.http.util.Args; * * @since 4.3 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) @SuppressWarnings("deprecation") class MinimalHttpClient extends CloseableHttpClient { diff --git a/httpclient/src/main/java/org/apache/http/impl/client/NoopUserTokenHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/NoopUserTokenHandler.java index 9d21a6b86..3ab1799c5 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/NoopUserTokenHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/NoopUserTokenHandler.java @@ -26,7 +26,8 @@ */ package org.apache.http.impl.client; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.UserTokenHandler; import org.apache.http.protocol.HttpContext; @@ -35,7 +36,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class NoopUserTokenHandler implements UserTokenHandler { public static final NoopUserTokenHandler INSTANCE = new NoopUserTokenHandler(); diff --git a/httpclient/src/main/java/org/apache/http/impl/client/ProxyAuthenticationStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/ProxyAuthenticationStrategy.java index 49e6e9122..2dba232b0 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/ProxyAuthenticationStrategy.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/ProxyAuthenticationStrategy.java @@ -30,7 +30,8 @@ package org.apache.http.impl.client; import java.util.Collection; import org.apache.http.HttpStatus; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AUTH; import org.apache.http.client.config.RequestConfig; @@ -40,7 +41,7 @@ import org.apache.http.client.config.RequestConfig; * * @since 4.2 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class ProxyAuthenticationStrategy extends AuthenticationStrategyImpl { public static final ProxyAuthenticationStrategy INSTANCE = new ProxyAuthenticationStrategy(); diff --git a/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java b/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java index e0d44648e..e583b52b7 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java @@ -35,15 +35,12 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import org.apache.http.annotation.NotThreadSafe; - /** * This class represents a collection of {@link java.net.URI}s used * as redirect locations. * * @since 4.0 */ -@NotThreadSafe // HashSet/ArrayList are not synch. public class RedirectLocations extends AbstractList { private final Set unique; diff --git a/httpclient/src/main/java/org/apache/http/impl/client/RequestWrapper.java b/httpclient/src/main/java/org/apache/http/impl/client/RequestWrapper.java index be6a743ab..61eb5d1e4 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/RequestWrapper.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/RequestWrapper.java @@ -34,7 +34,6 @@ import org.apache.http.HttpRequest; import org.apache.http.ProtocolException; import org.apache.http.ProtocolVersion; import org.apache.http.RequestLine; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.message.AbstractHttpMessage; import org.apache.http.message.BasicRequestLine; @@ -54,7 +53,6 @@ import org.apache.http.util.Args; * * @deprecated (4.3) do not use. */ -@NotThreadSafe @Deprecated public class RequestWrapper extends AbstractHttpMessage implements HttpUriRequest { diff --git a/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java index ae3342bf5..0680c133d 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java @@ -32,7 +32,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.http.HttpRequest; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; /** * {@link org.apache.http.client.HttpRequestRetryHandler} which assumes @@ -45,7 +46,7 @@ import org.apache.http.annotation.Immutable; * * @since 4.2 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class StandardHttpRequestRetryHandler extends DefaultHttpRequestRetryHandler { private final Map idempotentMethods; diff --git a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java index 8a160d914..f6f30ccfe 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java @@ -33,7 +33,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.http.HttpHost; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScope; import org.apache.http.auth.Credentials; import org.apache.http.auth.NTCredentials; @@ -48,7 +49,7 @@ import org.apache.http.util.Args; * * @since 4.3 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class SystemDefaultCredentialsProvider implements CredentialsProvider { private static final Map SCHEME_MAP; diff --git a/httpclient/src/main/java/org/apache/http/impl/client/TargetAuthenticationStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/TargetAuthenticationStrategy.java index dad2eb712..5737d745c 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/TargetAuthenticationStrategy.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/TargetAuthenticationStrategy.java @@ -30,7 +30,8 @@ package org.apache.http.impl.client; import java.util.Collection; import org.apache.http.HttpStatus; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AUTH; import org.apache.http.client.config.RequestConfig; @@ -40,7 +41,7 @@ import org.apache.http.client.config.RequestConfig; * * @since 4.2 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class TargetAuthenticationStrategy extends AuthenticationStrategyImpl { public static final TargetAuthenticationStrategy INSTANCE = new TargetAuthenticationStrategy(); diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java b/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java index 92ca64461..08153cdd1 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java @@ -38,8 +38,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpClientConnection; import org.apache.http.HttpHost; -import org.apache.http.annotation.GuardedBy; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.config.ConnectionConfig; import org.apache.http.config.Lookup; import org.apache.http.config.Registry; @@ -50,8 +50,8 @@ import org.apache.http.conn.DnsResolver; import org.apache.http.conn.HttpClientConnectionManager; import org.apache.http.conn.HttpClientConnectionOperator; import org.apache.http.conn.HttpConnectionFactory; -import org.apache.http.conn.SchemePortResolver; import org.apache.http.conn.ManagedHttpClientConnection; +import org.apache.http.conn.SchemePortResolver; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.conn.socket.PlainConnectionSocketFactory; @@ -79,7 +79,7 @@ import org.apache.http.util.LangUtils; * * @since 4.3 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) public class BasicHttpClientConnectionManager implements HttpClientConnectionManager, Closeable { private final Log log = LogFactory.getLog(getClass()); @@ -87,28 +87,13 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan private final HttpClientConnectionOperator connectionOperator; private final HttpConnectionFactory connFactory; - @GuardedBy("this") private ManagedHttpClientConnection conn; - - @GuardedBy("this") private HttpRoute route; - - @GuardedBy("this") private Object state; - - @GuardedBy("this") private long updated; - - @GuardedBy("this") private long expiry; - - @GuardedBy("this") private boolean leased; - - @GuardedBy("this") private SocketConfig socketConfig; - - @GuardedBy("this") private ConnectionConfig connConfig; private final AtomicBoolean isShutdown; diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java b/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java index f9cc0d6a6..eee9b78d7 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java @@ -31,7 +31,8 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.ManagedHttpClientConnection; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.pool.AbstractConnPool; @@ -41,7 +42,7 @@ import org.apache.http.pool.PoolEntryCallback; /** * @since 4.3 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) class CPool extends AbstractConnPool { private static final AtomicLong COUNTER = new AtomicLong(); diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java index 71f918393..cb89d27c7 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java @@ -32,7 +32,8 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.http.HttpClientConnection; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.ManagedHttpClientConnection; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.pool.PoolEntry; @@ -40,7 +41,7 @@ import org.apache.http.pool.PoolEntry; /** * @since 4.3 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) class CPoolEntry extends PoolEntry { private final Log log; diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java index 27b7f8766..8c8f623da 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java @@ -38,14 +38,12 @@ import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpException; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.conn.ManagedHttpClientConnection; import org.apache.http.protocol.HttpContext; /** * @since 4.3 */ -@NotThreadSafe class CPoolProxy implements ManagedHttpClientConnection, HttpContext { private volatile CPoolEntry poolEntry; diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java b/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java index b0b6bb6ae..1737fbb6b 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java @@ -27,15 +27,12 @@ package org.apache.http.impl.conn; -import org.apache.http.annotation.Immutable; - /** * Signals that the connection has been shut down or released back to the * the connection pool * * @since 4.1 */ -@Immutable public class ConnectionShutdownException extends IllegalStateException { private static final long serialVersionUID = 5868657401162844497L; diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java index 582136408..76af8e81b 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java @@ -37,7 +37,8 @@ import java.net.SocketTimeoutException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpHost; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.config.Lookup; import org.apache.http.config.SocketConfig; @@ -60,7 +61,7 @@ import org.apache.http.util.Args; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class DefaultHttpClientConnectionOperator implements HttpClientConnectionOperator { static final String SOCKET_FACTORY_REGISTRY = "http.socket-factory-registry"; diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java index c685bf276..e5578ecfe 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java @@ -37,7 +37,6 @@ import org.apache.http.HttpResponseFactory; import org.apache.http.NoHttpResponseException; import org.apache.http.ProtocolException; import org.apache.http.StatusLine; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.config.MessageConstraints; import org.apache.http.impl.DefaultHttpResponseFactory; import org.apache.http.impl.io.AbstractMessageParser; @@ -55,7 +54,6 @@ import org.apache.http.util.CharArrayBuffer; * @since 4.2 */ @SuppressWarnings("deprecation") -@NotThreadSafe public class DefaultHttpResponseParser extends AbstractMessageParser { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParserFactory.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParserFactory.java index f5c0af01f..93d281906 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParserFactory.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParserFactory.java @@ -29,7 +29,8 @@ package org.apache.http.impl.conn; import org.apache.http.HttpResponse; import org.apache.http.HttpResponseFactory; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.config.MessageConstraints; import org.apache.http.impl.DefaultHttpResponseFactory; import org.apache.http.io.HttpMessageParser; @@ -43,7 +44,7 @@ import org.apache.http.message.LineParser; * * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class DefaultHttpResponseParserFactory implements HttpMessageParserFactory { public static final DefaultHttpResponseParserFactory INSTANCE = new DefaultHttpResponseParserFactory(); diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java index 7eabfac65..1a74f5ea9 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java @@ -40,7 +40,6 @@ import javax.net.ssl.SSLSocket; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.config.MessageConstraints; import org.apache.http.conn.ManagedHttpClientConnection; import org.apache.http.entity.ContentLengthStrategy; @@ -53,7 +52,6 @@ import org.apache.http.protocol.HttpContext; * Default {@link ManagedHttpClientConnection} implementation. * @since 4.3 */ -@NotThreadSafe public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnection implements ManagedHttpClientConnection, HttpContext { diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java index 376654a06..12a67d725 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java @@ -30,7 +30,8 @@ package org.apache.http.impl.conn; import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.SchemePortResolver; import org.apache.http.protocol.HttpContext; import org.apache.http.util.Args; @@ -41,7 +42,7 @@ import org.apache.http.util.Args; * * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class DefaultProxyRoutePlanner extends DefaultRoutePlanner { private final HttpHost proxy; diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java index b56d2f8ed..3652115c1 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java @@ -33,7 +33,8 @@ import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.conn.SchemePortResolver; @@ -49,7 +50,7 @@ import org.apache.http.util.Args; * * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class DefaultRoutePlanner implements HttpRoutePlanner { private final SchemePortResolver schemePortResolver; diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultSchemePortResolver.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultSchemePortResolver.java index c5d54ed9f..aaff79c58 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultSchemePortResolver.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultSchemePortResolver.java @@ -27,7 +27,8 @@ package org.apache.http.impl.conn; import org.apache.http.HttpHost; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.SchemePortResolver; import org.apache.http.conn.UnsupportedSchemeException; import org.apache.http.util.Args; @@ -37,7 +38,7 @@ import org.apache.http.util.Args; * * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class DefaultSchemePortResolver implements SchemePortResolver { public static final DefaultSchemePortResolver INSTANCE = new DefaultSchemePortResolver(); diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java index c47e7c085..90b2435e7 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java @@ -27,8 +27,6 @@ package org.apache.http.impl.conn; -import org.apache.http.annotation.NotThreadSafe; - import java.io.IOException; import java.io.InputStream; @@ -37,7 +35,6 @@ import java.io.InputStream; * * @since 4.3 */ -@NotThreadSafe class LoggingInputStream extends InputStream { private final InputStream in; diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java index 2614b0c9b..6d3b34fe6 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java @@ -27,16 +27,6 @@ package org.apache.http.impl.conn; -import org.apache.commons.logging.Log; -import org.apache.http.Header; -import org.apache.http.HttpRequest; -import org.apache.http.HttpResponse; -import org.apache.http.annotation.NotThreadSafe; -import org.apache.http.config.MessageConstraints; -import org.apache.http.entity.ContentLengthStrategy; -import org.apache.http.io.HttpMessageParserFactory; -import org.apache.http.io.HttpMessageWriterFactory; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -44,7 +34,15 @@ import java.net.Socket; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; -@NotThreadSafe +import org.apache.commons.logging.Log; +import org.apache.http.Header; +import org.apache.http.HttpRequest; +import org.apache.http.HttpResponse; +import org.apache.http.config.MessageConstraints; +import org.apache.http.entity.ContentLengthStrategy; +import org.apache.http.io.HttpMessageParserFactory; +import org.apache.http.io.HttpMessageWriterFactory; + class LoggingManagedHttpClientConnection extends DefaultManagedHttpClientConnection { private final Log log; diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java index b292453f4..3b084c12d 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java @@ -27,8 +27,6 @@ package org.apache.http.impl.conn; -import org.apache.http.annotation.NotThreadSafe; - import java.io.IOException; import java.io.OutputStream; @@ -37,7 +35,6 @@ import java.io.OutputStream; * * @since 4.3 */ -@NotThreadSafe class LoggingOutputStream extends OutputStream { private final OutputStream out; diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java b/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java index 2d7d521dc..7057c3e3f 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java @@ -37,7 +37,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.config.ConnectionConfig; import org.apache.http.conn.HttpConnectionFactory; import org.apache.http.conn.ManagedHttpClientConnection; @@ -53,7 +54,7 @@ import org.apache.http.io.HttpMessageWriterFactory; * Factory for {@link ManagedHttpClientConnection} instances. * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory { diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java b/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java index 0389a43d9..81928acb5 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java @@ -42,7 +42,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpClientConnection; import org.apache.http.HttpHost; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.config.ConnectionConfig; import org.apache.http.config.Lookup; import org.apache.http.config.Registry; @@ -99,7 +100,7 @@ import org.apache.http.util.Asserts; * * @since 4.3 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) public class PoolingHttpClientConnectionManager implements HttpClientConnectionManager, ConnPoolControl, Closeable { diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/SystemDefaultRoutePlanner.java b/httpclient/src/main/java/org/apache/http/impl/conn/SystemDefaultRoutePlanner.java index 30de52c19..b4cac8b71 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/SystemDefaultRoutePlanner.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/SystemDefaultRoutePlanner.java @@ -37,7 +37,8 @@ import java.util.List; import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.SchemePortResolver; import org.apache.http.protocol.HttpContext; @@ -49,7 +50,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class SystemDefaultRoutePlanner extends DefaultRoutePlanner { private final ProxySelector proxySelector; 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 e3bffd33f..48195e5f0 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 @@ -31,7 +31,8 @@ import java.io.IOException; import java.io.InputStream; import org.apache.commons.logging.Log; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.util.Args; /** @@ -40,7 +41,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.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 ccf12dd5b..80408a9f4 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 @@ -26,7 +26,8 @@ */ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieAttributeHandler; import org.apache.http.cookie.CookieOrigin; @@ -36,7 +37,7 @@ import org.apache.http.cookie.MalformedCookieException; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public abstract class AbstractCookieAttributeHandler implements CookieAttributeHandler { @Override diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java index 1c6914a6e..c0c7c5b9f 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java @@ -32,7 +32,8 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.CookieAttributeHandler; import org.apache.http.cookie.CookieSpec; @@ -47,7 +48,7 @@ import org.apache.http.util.Asserts; * * @since 4.0 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public abstract class AbstractCookieSpec implements CookieSpec { /** diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java index dc261ab59..e5503bc91 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java @@ -33,7 +33,6 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.SetCookie; import org.apache.http.util.Args; @@ -43,7 +42,6 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@NotThreadSafe public class BasicClientCookie implements SetCookie, ClientCookie, Cloneable, Serializable { private static final long serialVersionUID = -3869795591041535538L; diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie2.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie2.java index e9c50a302..9a191ffe8 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie2.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie2.java @@ -29,7 +29,6 @@ package org.apache.http.impl.cookie; import java.util.Date; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.cookie.SetCookie2; /** @@ -37,7 +36,6 @@ import org.apache.http.cookie.SetCookie2; * * @since 4.0 */ -@NotThreadSafe public class BasicClientCookie2 extends BasicClientCookie implements SetCookie2 { private static final long serialVersionUID = -7744598295706617057L; 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 14c9cfe59..3bd7794f6 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 @@ -26,7 +26,8 @@ */ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.MalformedCookieException; @@ -37,7 +38,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class BasicCommentHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler { 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 7503971b5..c5e902e35 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 @@ -28,7 +28,8 @@ package org.apache.http.impl.cookie; import java.util.Locale; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.util.InetAddressUtils; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; @@ -44,7 +45,7 @@ import org.apache.http.util.TextUtils; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class BasicDomainHandler implements CommonCookieAttributeHandler { 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 21a28766e..2db2194e9 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 @@ -28,7 +28,8 @@ package org.apache.http.impl.cookie; import java.util.Date; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.utils.DateUtils; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; @@ -40,7 +41,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class BasicExpiresHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler { /** 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 02ee8babb..0914bf6f0 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 @@ -28,7 +28,8 @@ package org.apache.http.impl.cookie; import java.util.Date; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.MalformedCookieException; @@ -39,7 +40,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class BasicMaxAgeHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler { 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 c7b387567..4a435cf1d 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 @@ -26,7 +26,8 @@ */ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.Cookie; @@ -41,7 +42,7 @@ import org.apache.http.util.TextUtils; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class BasicPathHandler implements CommonCookieAttributeHandler { 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 5b8f55cc8..9d782a4c9 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 @@ -26,7 +26,8 @@ */ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.Cookie; @@ -39,7 +40,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class BasicSecureHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler { public BasicSecureHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java b/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java index f4f98f191..5fca8bd3b 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java @@ -34,7 +34,8 @@ import java.util.Locale; import org.apache.http.HeaderElement; import org.apache.http.NameValuePair; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieAttributeHandler; @@ -47,7 +48,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public abstract class CookieSpecBase extends AbstractCookieSpec { public CookieSpecBase() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java index bd571ced4..c291f1c41 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java @@ -32,7 +32,8 @@ import java.util.List; import org.apache.http.FormattedHeader; import org.apache.http.Header; import org.apache.http.HeaderElement; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieOrigin; import org.apache.http.cookie.CookieSpec; @@ -49,7 +50,7 @@ import org.apache.http.util.CharArrayBuffer; * * @since 4.4 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class DefaultCookieSpec implements CookieSpec { private final RFC2965Spec strict; diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java b/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java index 1fe8f0345..4aa213fa8 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java @@ -27,7 +27,8 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.util.PublicSuffixMatcher; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieOrigin; @@ -43,7 +44,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class DefaultCookieSpecProvider implements CookieSpecProvider { public enum CompatibilityLevel { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpec.java index 71bf7902f..579b8d805 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpec.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpec.java @@ -31,7 +31,8 @@ import java.util.Collections; import java.util.List; import org.apache.http.Header; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieOrigin; import org.apache.http.cookie.MalformedCookieException; @@ -41,7 +42,7 @@ import org.apache.http.cookie.MalformedCookieException; * * @since 4.1 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class IgnoreSpec extends CookieSpecBase { @Override diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecProvider.java b/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecProvider.java index 97bedf6d1..063958be7 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecProvider.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecProvider.java @@ -27,7 +27,8 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecProvider; import org.apache.http.protocol.HttpContext; @@ -37,7 +38,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class IgnoreSpecProvider implements CookieSpecProvider { private volatile CookieSpec cookieSpec; diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java index 82e891c98..8043bb48a 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java @@ -35,7 +35,8 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.MalformedCookieException; @@ -47,7 +48,7 @@ import org.apache.http.util.Args; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class LaxExpiresHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler { static final TimeZone UTC = TimeZone.getTimeZone("UTC"); diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/LaxMaxAgeHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/LaxMaxAgeHandler.java index 8615286e8..e4404699d 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/LaxMaxAgeHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/LaxMaxAgeHandler.java @@ -30,7 +30,8 @@ import java.util.Date; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.MalformedCookieException; @@ -42,7 +43,7 @@ import org.apache.http.util.TextUtils; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class LaxMaxAgeHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler { private final static Pattern MAX_AGE_PATTERN = Pattern.compile("^\\-?[0-9]+$"); 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 1f92cc08d..c187d4ae8 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 @@ -29,7 +29,8 @@ package org.apache.http.impl.cookie; import java.util.Locale; import java.util.StringTokenizer; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieOrigin; @@ -43,7 +44,7 @@ import org.apache.http.util.TextUtils; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.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 a6a40de77..3c13a67f2 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,7 +34,8 @@ import java.util.List; import org.apache.http.HeaderElement; import org.apache.http.NameValuePair; import org.apache.http.ParseException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.message.BasicHeaderElement; import org.apache.http.message.BasicNameValuePair; import org.apache.http.message.ParserCursor; @@ -46,7 +47,7 @@ import org.apache.http.util.CharArrayBuffer; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.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 caedd83ad..968db73a7 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 @@ -33,8 +33,9 @@ import java.util.List; import org.apache.http.FormattedHeader; import org.apache.http.Header; import org.apache.http.HeaderElement; +import org.apache.http.annotation.Contract; import org.apache.http.annotation.Obsolete; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieOrigin; @@ -57,7 +58,7 @@ import org.apache.http.util.CharArrayBuffer; * @see org.apache.http.impl.cookie.RFC6265LaxSpec */ @Obsolete -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class NetscapeDraftSpec extends CookieSpecBase { protected static final String EXPIRES_PATTERN = "EEE, dd-MMM-yy HH:mm:ss z"; diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecProvider.java b/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecProvider.java index f4832f771..06b9b8e5d 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecProvider.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpecProvider.java @@ -27,8 +27,9 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; import org.apache.http.annotation.Obsolete; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecProvider; import org.apache.http.protocol.HttpContext; @@ -44,7 +45,7 @@ import org.apache.http.protocol.HttpContext; * @see org.apache.http.impl.cookie.RFC6265CookieSpecProvider */ @Obsolete -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class NetscapeDraftSpecProvider implements CookieSpecProvider { private final String[] datepatterns; diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixDomainFilter.java b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixDomainFilter.java index 062f8ec6a..24d37283c 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixDomainFilter.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixDomainFilter.java @@ -29,7 +29,8 @@ package org.apache.http.impl.cookie; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.util.PublicSuffixList; import org.apache.http.conn.util.PublicSuffixMatcher; import org.apache.http.cookie.CommonCookieAttributeHandler; @@ -50,7 +51,7 @@ import org.apache.http.util.Args; * * @since 4.4 */ -@Immutable // dependencies are expected to be immutable or thread-safe +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class PublicSuffixDomainFilter implements CommonCookieAttributeHandler { private final CommonCookieAttributeHandler handler; 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 fdbeb1532..e0a0b8a3f 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 @@ -28,7 +28,8 @@ package org.apache.http.impl.cookie; import java.util.Locale; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.Cookie; @@ -42,7 +43,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RFC2109DomainHandler implements CommonCookieAttributeHandler { public RFC2109DomainHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java index 1b4e783ef..668839c8e 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java @@ -33,8 +33,9 @@ import java.util.List; import org.apache.http.Header; import org.apache.http.HeaderElement; +import org.apache.http.annotation.Contract; import org.apache.http.annotation.Obsolete; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.utils.DateUtils; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; @@ -57,7 +58,7 @@ import org.apache.http.util.CharArrayBuffer; * @see org.apache.http.impl.cookie.RFC6265StrictSpec */ @Obsolete -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class RFC2109Spec extends CookieSpecBase { final static String[] DATE_PATTERNS = { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecProvider.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecProvider.java index c7f972482..2390a447a 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecProvider.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109SpecProvider.java @@ -27,8 +27,9 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; import org.apache.http.annotation.Obsolete; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.util.PublicSuffixMatcher; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecProvider; @@ -45,7 +46,7 @@ import org.apache.http.protocol.HttpContext; * @see org.apache.http.impl.cookie.RFC6265CookieSpecProvider */ @Obsolete -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class RFC2109SpecProvider implements CookieSpecProvider { private final PublicSuffixMatcher publicSuffixMatcher; 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 a342e851a..888a6f5d3 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 @@ -26,7 +26,8 @@ */ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.Cookie; @@ -40,7 +41,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RFC2109VersionHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler { 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 dd739bce5..db6b7d2d6 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 @@ -27,7 +27,8 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.Cookie; @@ -41,7 +42,7 @@ import org.apache.http.cookie.SetCookie2; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RFC2965CommentUrlAttributeHandler implements CommonCookieAttributeHandler { public RFC2965CommentUrlAttributeHandler() { 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 62d1f453e..4ffd574c0 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 @@ -27,7 +27,8 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.Cookie; @@ -41,7 +42,7 @@ import org.apache.http.cookie.SetCookie2; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RFC2965DiscardAttributeHandler implements CommonCookieAttributeHandler { public RFC2965DiscardAttributeHandler() { 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 42e790e56..ee98a1b4a 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 @@ -29,7 +29,8 @@ package org.apache.http.impl.cookie; import java.util.Locale; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.Cookie; @@ -45,7 +46,7 @@ import org.apache.http.util.Args; * * @since 3.1 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RFC2965DomainAttributeHandler implements CommonCookieAttributeHandler { 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 004f25473..e3fdc8eb6 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 @@ -29,7 +29,8 @@ package org.apache.http.impl.cookie; import java.util.StringTokenizer; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.Cookie; @@ -45,7 +46,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RFC2965PortAttributeHandler implements CommonCookieAttributeHandler { public RFC2965PortAttributeHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java index ca836c12e..08fd4e85a 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java @@ -35,8 +35,9 @@ import java.util.Map; import org.apache.http.Header; import org.apache.http.HeaderElement; import org.apache.http.NameValuePair; +import org.apache.http.annotation.Contract; import org.apache.http.annotation.Obsolete; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.Cookie; @@ -57,7 +58,7 @@ import org.apache.http.util.CharArrayBuffer; * @see org.apache.http.impl.cookie.RFC6265StrictSpec */ @Obsolete -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class RFC2965Spec extends RFC2109Spec { /** diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecProvider.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecProvider.java index ba303a67d..4c6d932ca 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecProvider.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965SpecProvider.java @@ -27,8 +27,9 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; import org.apache.http.annotation.Obsolete; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.util.PublicSuffixMatcher; import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecProvider; @@ -45,7 +46,7 @@ import org.apache.http.protocol.HttpContext; * @see org.apache.http.impl.cookie.RFC6265CookieSpecProvider */ @Obsolete -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class RFC2965SpecProvider implements CookieSpecProvider { private final PublicSuffixMatcher publicSuffixMatcher; diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java index ac682d8cb..9833a0ec5 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java @@ -27,7 +27,8 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.Cookie; @@ -43,7 +44,7 @@ import org.apache.http.util.Args; * * @since 4.0 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE) public class RFC2965VersionAttributeHandler implements CommonCookieAttributeHandler { public RFC2965VersionAttributeHandler() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java index 22d7d1dbd..7368dcfe2 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java @@ -39,7 +39,8 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.http.FormattedHeader; import org.apache.http.Header; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.ClientCookie; import org.apache.http.cookie.CommonCookieAttributeHandler; import org.apache.http.cookie.Cookie; @@ -60,7 +61,7 @@ import org.apache.http.util.CharArrayBuffer; * * @since 4.5 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class RFC6265CookieSpec implements CookieSpec { private final static char PARAM_DELIMITER = ';'; diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpecProvider.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpecProvider.java index e4f24dc17..69bedce5c 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpecProvider.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpecProvider.java @@ -27,7 +27,8 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.conn.util.PublicSuffixMatcher; import org.apache.http.cookie.Cookie; import org.apache.http.cookie.CookieOrigin; @@ -43,7 +44,7 @@ import org.apache.http.protocol.HttpContext; * * @since 4.4 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class RFC6265CookieSpecProvider implements CookieSpecProvider { public enum CompatibilityLevel { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265LaxSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265LaxSpec.java index 8455c8342..56b26daa7 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265LaxSpec.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265LaxSpec.java @@ -27,7 +27,8 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.cookie.CommonCookieAttributeHandler; /** @@ -38,7 +39,7 @@ import org.apache.http.cookie.CommonCookieAttributeHandler; * * @since 4.4 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class RFC6265LaxSpec extends RFC6265CookieSpecBase { public RFC6265LaxSpec() { diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265StrictSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265StrictSpec.java index 1765d276f..635b3f549 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265StrictSpec.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265StrictSpec.java @@ -27,7 +27,8 @@ package org.apache.http.impl.cookie; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.utils.DateUtils; import org.apache.http.cookie.CommonCookieAttributeHandler; @@ -38,7 +39,7 @@ import org.apache.http.cookie.CommonCookieAttributeHandler; * * @since 4.4 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) public class RFC6265StrictSpec extends RFC6265CookieSpecBase { final static String[] DATE_PATTERNS = { diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java index 7c9025b5b..598c62f2c 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java @@ -31,7 +31,8 @@ import java.io.IOException; import java.lang.reflect.UndeclaredThrowableException; import org.apache.http.HttpException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.BackoffManager; import org.apache.http.client.ConnectionBackoffStrategy; import org.apache.http.client.methods.CloseableHttpResponse; @@ -44,7 +45,7 @@ import org.apache.http.util.Args; /** * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class BackoffStrategyExec implements ClientExecChain { private final ClientExecChain requestExecutor; diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java index 0f6e4f3e8..daa5a319f 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java @@ -34,7 +34,8 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.apache.commons.logging.Log; import org.apache.http.HttpClientConnection; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.concurrent.Cancellable; import org.apache.http.conn.ConnectionReleaseTrigger; import org.apache.http.conn.HttpClientConnectionManager; @@ -44,7 +45,7 @@ import org.apache.http.conn.HttpClientConnectionManager; * * @since 4.3 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.SAFE) class ConnectionHolder implements ConnectionReleaseTrigger, Cancellable, Closeable { private final Log log; diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/HttpResponseProxy.java b/httpclient/src/main/java/org/apache/http/impl/execchain/HttpResponseProxy.java index 0184ec250..533eb704f 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/HttpResponseProxy.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/HttpResponseProxy.java @@ -36,7 +36,6 @@ import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.ProtocolVersion; import org.apache.http.StatusLine; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.params.HttpParams; @@ -46,7 +45,6 @@ import org.apache.http.params.HttpParams; * * @since 4.3 */ -@NotThreadSafe class HttpResponseProxy implements CloseableHttpResponse { private final HttpResponse original; diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java index 949681300..a932a08c1 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java @@ -42,7 +42,8 @@ import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AUTH; import org.apache.http.auth.AuthProtocolState; import org.apache.http.auth.AuthState; @@ -84,7 +85,7 @@ import org.apache.http.util.EntityUtils; * @since 4.3 */ @SuppressWarnings("deprecation") -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class MainClientExec implements ClientExecChain { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java index adca0a25e..bc8290438 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java @@ -44,7 +44,8 @@ import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpExecutionAware; @@ -77,7 +78,7 @@ import org.apache.http.util.VersionInfo; * * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class MinimalClientExec implements ClientExecChain { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ProtocolExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ProtocolExec.java index 0f9b75c57..ea3da2c97 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/ProtocolExec.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ProtocolExec.java @@ -37,7 +37,8 @@ import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.ProtocolException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; @@ -69,7 +70,7 @@ import org.apache.http.util.Args; * * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) @SuppressWarnings("deprecation") public class ProtocolExec implements ClientExecChain { diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java index dcafdb55c..37549e1c0 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java @@ -38,7 +38,8 @@ import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.ProtocolException; -import org.apache.http.annotation.ThreadSafe; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthState; import org.apache.http.client.RedirectException; @@ -65,7 +66,7 @@ import org.apache.http.util.EntityUtils; * * @since 4.3 */ -@ThreadSafe +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class RedirectExec implements ClientExecChain { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/RequestAbortedException.java b/httpclient/src/main/java/org/apache/http/impl/execchain/RequestAbortedException.java index 2a3d0a5f3..4ccde500a 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/RequestAbortedException.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/RequestAbortedException.java @@ -29,14 +29,11 @@ package org.apache.http.impl.execchain; import java.io.InterruptedIOException; -import org.apache.http.annotation.Immutable; - /** * Signals that the request has been aborted. * * @since 4.3 */ -@Immutable public class RequestAbortedException extends InterruptedIOException { private static final long serialVersionUID = 4973849966012490112L; diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java b/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java index e4ed35b66..1affd94a9 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java @@ -34,14 +34,12 @@ import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpRequest; -import org.apache.http.annotation.NotThreadSafe; /** * A Proxy class for {@link org.apache.http.HttpEntity} enclosed in a request message. * * @since 4.3 */ -@NotThreadSafe class RequestEntityProxy implements HttpEntity { static void enhance(final HttpEntityEnclosingRequest request) { diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java index ba2716326..7013e09eb 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java @@ -34,7 +34,6 @@ import java.net.SocketException; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; -import org.apache.http.annotation.NotThreadSafe; import org.apache.http.conn.EofSensorInputStream; import org.apache.http.conn.EofSensorWatcher; import org.apache.http.entity.HttpEntityWrapper; @@ -44,7 +43,6 @@ import org.apache.http.entity.HttpEntityWrapper; * * @since 4.3 */ -@NotThreadSafe class ResponseEntityProxy extends HttpEntityWrapper implements EofSensorWatcher { private final ConnectionHolder connHolder; diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java index cade16405..201733e9b 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java @@ -34,7 +34,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.http.Header; import org.apache.http.HttpException; import org.apache.http.NoHttpResponseException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.HttpRequestRetryHandler; import org.apache.http.client.NonRepeatableRequestException; import org.apache.http.client.methods.CloseableHttpResponse; @@ -56,7 +57,7 @@ import org.apache.http.util.Args; * * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class RetryExec implements ClientExecChain { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ServiceUnavailableRetryExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ServiceUnavailableRetryExec.java index 6fb6ef39d..8b0c6f434 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/ServiceUnavailableRetryExec.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ServiceUnavailableRetryExec.java @@ -34,7 +34,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.Header; import org.apache.http.HttpException; -import org.apache.http.annotation.Immutable; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.ServiceUnavailableRetryStrategy; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpExecutionAware; @@ -55,7 +56,7 @@ import org.apache.http.util.Args; * * @since 4.3 */ -@Immutable +@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class ServiceUnavailableRetryExec implements ClientExecChain { private final Log log = LogFactory.getLog(getClass()); diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/TunnelRefusedException.java b/httpclient/src/main/java/org/apache/http/impl/execchain/TunnelRefusedException.java index cff1e0797..1b993ac07 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/TunnelRefusedException.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/TunnelRefusedException.java @@ -29,14 +29,12 @@ package org.apache.http.impl.execchain; import org.apache.http.HttpException; import org.apache.http.HttpResponse; -import org.apache.http.annotation.Immutable; /** * Signals that the tunnel request was rejected by the proxy host. * * @since 4.0 */ -@Immutable public class TunnelRefusedException extends HttpException { private static final long serialVersionUID = -8646722842745617323L; diff --git a/pom.xml b/pom.xml index 8a12f46ef..a5b9d79fa 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,7 @@ 1.6 1.6 - 4.4.4 + 4.4.5 1.2 1.9 2.6.9