Add thread-safety annotations
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@939883 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
16a8c31100
commit
8e89d40f37
|
@ -30,6 +30,7 @@ import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.http.annotation.ThreadSafe;
|
||||||
import org.apache.http.client.cache.HttpCacheOperationException;
|
import org.apache.http.client.cache.HttpCacheOperationException;
|
||||||
import org.apache.http.client.cache.HttpCacheUpdateCallback;
|
import org.apache.http.client.cache.HttpCacheUpdateCallback;
|
||||||
import org.apache.http.client.cache.HttpCache;
|
import org.apache.http.client.cache.HttpCache;
|
||||||
|
@ -39,6 +40,7 @@ import org.apache.http.client.cache.HttpCache;
|
||||||
*
|
*
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@ThreadSafe
|
||||||
public class BasicHttpCache implements HttpCache<CacheEntry> {
|
public class BasicHttpCache implements HttpCache<CacheEntry> {
|
||||||
|
|
||||||
private final LinkedHashMap<String, CacheEntry> baseMap = new LinkedHashMap<String, CacheEntry>(20,
|
private final LinkedHashMap<String, CacheEntry> baseMap = new LinkedHashMap<String, CacheEntry>(20,
|
||||||
|
|
|
@ -30,10 +30,12 @@ import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.annotation.Immutable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class CacheEntryGenerator {
|
public class CacheEntryGenerator {
|
||||||
|
|
||||||
public CacheEntry generateEntry(Date requestDate, Date responseDate, HttpResponse response,
|
public CacheEntry generateEntry(Date requestDate, Date responseDate, HttpResponse response,
|
||||||
|
|
|
@ -34,12 +34,14 @@ import java.util.ListIterator;
|
||||||
|
|
||||||
import org.apache.http.Header;
|
import org.apache.http.Header;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.annotation.Immutable;
|
||||||
import org.apache.http.impl.cookie.DateParseException;
|
import org.apache.http.impl.cookie.DateParseException;
|
||||||
import org.apache.http.impl.cookie.DateUtils;
|
import org.apache.http.impl.cookie.DateUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class CacheEntryUpdater {
|
public class CacheEntryUpdater {
|
||||||
|
|
||||||
public void updateCacheEntry(CacheEntry entry, Date requestDate, Date responseDate,
|
public void updateCacheEntry(CacheEntry entry, Date requestDate, Date responseDate,
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.http.Header;
|
||||||
import org.apache.http.HeaderElement;
|
import org.apache.http.HeaderElement;
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
import org.apache.http.HttpRequest;
|
import org.apache.http.HttpRequest;
|
||||||
|
import org.apache.http.annotation.Immutable;
|
||||||
import org.apache.http.client.cache.HttpCacheOperationException;
|
import org.apache.http.client.cache.HttpCacheOperationException;
|
||||||
import org.apache.http.client.cache.HttpCache;
|
import org.apache.http.client.cache.HttpCache;
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ import org.apache.http.client.cache.HttpCache;
|
||||||
*
|
*
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class CacheInvalidator {
|
public class CacheInvalidator {
|
||||||
|
|
||||||
private final HttpCache<CacheEntry> cache;
|
private final HttpCache<CacheEntry> cache;
|
||||||
|
|
|
@ -32,12 +32,14 @@ import org.apache.http.Header;
|
||||||
import org.apache.http.HeaderElement;
|
import org.apache.http.HeaderElement;
|
||||||
import org.apache.http.HttpRequest;
|
import org.apache.http.HttpRequest;
|
||||||
import org.apache.http.ProtocolVersion;
|
import org.apache.http.ProtocolVersion;
|
||||||
|
import org.apache.http.annotation.Immutable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if an HttpRequest is allowed to be served from the cache.
|
* Determines if an HttpRequest is allowed to be served from the cache.
|
||||||
*
|
*
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class CacheableRequestPolicy {
|
public class CacheableRequestPolicy {
|
||||||
|
|
||||||
private static final Log LOG = LogFactory.getLog(CacheableRequestPolicy.class);
|
private static final Log LOG = LogFactory.getLog(CacheableRequestPolicy.class);
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.http.Header;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
|
import org.apache.http.annotation.Immutable;
|
||||||
import org.apache.http.entity.ByteArrayEntity;
|
import org.apache.http.entity.ByteArrayEntity;
|
||||||
import org.apache.http.message.BasicHeader;
|
import org.apache.http.message.BasicHeader;
|
||||||
import org.apache.http.message.BasicHttpResponse;
|
import org.apache.http.message.BasicHttpResponse;
|
||||||
|
@ -39,6 +40,7 @@ import org.apache.http.message.BasicHttpResponse;
|
||||||
*
|
*
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class CachedHttpResponseGenerator {
|
public class CachedHttpResponseGenerator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,12 +32,14 @@ import org.apache.http.Header;
|
||||||
import org.apache.http.HeaderElement;
|
import org.apache.http.HeaderElement;
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
import org.apache.http.HttpRequest;
|
import org.apache.http.HttpRequest;
|
||||||
|
import org.apache.http.annotation.Immutable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether a given response can be cached.
|
* Determines whether a given response can be cached.
|
||||||
*
|
*
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class CachedResponseSuitabilityChecker {
|
public class CachedResponseSuitabilityChecker {
|
||||||
|
|
||||||
private static final Log LOG = LogFactory.getLog(CachedResponseSuitabilityChecker.class);
|
private static final Log LOG = LogFactory.getLog(CachedResponseSuitabilityChecker.class);
|
||||||
|
|
|
@ -29,11 +29,13 @@ package org.apache.http.client.cache.impl;
|
||||||
import org.apache.http.Header;
|
import org.apache.http.Header;
|
||||||
import org.apache.http.HttpRequest;
|
import org.apache.http.HttpRequest;
|
||||||
import org.apache.http.ProtocolException;
|
import org.apache.http.ProtocolException;
|
||||||
|
import org.apache.http.annotation.Immutable;
|
||||||
import org.apache.http.impl.client.RequestWrapper;
|
import org.apache.http.impl.client.RequestWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class ConditionalRequestBuilder {
|
public class ConditionalRequestBuilder {
|
||||||
|
|
||||||
public HttpRequest buildConditionalRequest(HttpRequest request, CacheEntry cacheEntry)
|
public HttpRequest buildConditionalRequest(HttpRequest request, CacheEntry cacheEntry)
|
||||||
|
|
|
@ -32,6 +32,7 @@ import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import org.apache.http.annotation.Immutable;
|
||||||
import org.apache.http.client.cache.HttpCacheEntrySerializer;
|
import org.apache.http.client.cache.HttpCacheEntrySerializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,6 +43,7 @@ import org.apache.http.client.cache.HttpCacheEntrySerializer;
|
||||||
*
|
*
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class DefaultCacheEntrySerializer implements HttpCacheEntrySerializer<CacheEntry> {
|
public class DefaultCacheEntrySerializer implements HttpCacheEntrySerializer<CacheEntry> {
|
||||||
|
|
||||||
public void writeTo(CacheEntry cacheEntry, OutputStream os) throws IOException {
|
public void writeTo(CacheEntry cacheEntry, OutputStream os) throws IOException {
|
||||||
|
|
|
@ -26,9 +26,12 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.http.client.cache.impl;
|
package org.apache.http.client.cache.impl;
|
||||||
|
|
||||||
|
import org.apache.http.annotation.Immutable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class HeaderConstants {
|
public class HeaderConstants {
|
||||||
|
|
||||||
public static final String GET_METHOD = "GET";
|
public static final String GET_METHOD = "GET";
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.ProtocolException;
|
import org.apache.http.ProtocolException;
|
||||||
import org.apache.http.ProtocolVersion;
|
import org.apache.http.ProtocolVersion;
|
||||||
|
import org.apache.http.annotation.Immutable;
|
||||||
import org.apache.http.entity.AbstractHttpEntity;
|
import org.apache.http.entity.AbstractHttpEntity;
|
||||||
import org.apache.http.impl.client.RequestWrapper;
|
import org.apache.http.impl.client.RequestWrapper;
|
||||||
import org.apache.http.message.BasicHeader;
|
import org.apache.http.message.BasicHeader;
|
||||||
|
@ -46,6 +47,7 @@ import org.apache.http.message.BasicStatusLine;
|
||||||
/**
|
/**
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class RequestProtocolCompliance {
|
public class RequestProtocolCompliance {
|
||||||
|
|
||||||
public List<RequestProtocolError> requestIsFatallyNonCompliant(HttpRequest request) {
|
public List<RequestProtocolError> requestIsFatallyNonCompliant(HttpRequest request) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.http.HeaderElement;
|
||||||
import org.apache.http.HttpRequest;
|
import org.apache.http.HttpRequest;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
|
import org.apache.http.annotation.Immutable;
|
||||||
import org.apache.http.impl.cookie.DateParseException;
|
import org.apache.http.impl.cookie.DateParseException;
|
||||||
import org.apache.http.impl.cookie.DateUtils;
|
import org.apache.http.impl.cookie.DateUtils;
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ import org.apache.http.impl.cookie.DateUtils;
|
||||||
*
|
*
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class ResponseCachingPolicy {
|
public class ResponseCachingPolicy {
|
||||||
|
|
||||||
private final int maxObjectSizeBytes;
|
private final int maxObjectSizeBytes;
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.http.HttpRequest;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.ProtocolVersion;
|
import org.apache.http.ProtocolVersion;
|
||||||
|
import org.apache.http.annotation.Immutable;
|
||||||
import org.apache.http.client.ClientProtocolException;
|
import org.apache.http.client.ClientProtocolException;
|
||||||
import org.apache.http.impl.client.RequestWrapper;
|
import org.apache.http.impl.client.RequestWrapper;
|
||||||
import org.apache.http.impl.cookie.DateUtils;
|
import org.apache.http.impl.cookie.DateUtils;
|
||||||
|
@ -40,6 +41,7 @@ import org.apache.http.impl.cookie.DateUtils;
|
||||||
/**
|
/**
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class ResponseProtocolCompliance {
|
public class ResponseProtocolCompliance {
|
||||||
|
|
||||||
public void ensureProtocolCompliance(HttpRequest request, HttpResponse response)
|
public void ensureProtocolCompliance(HttpRequest request, HttpResponse response)
|
||||||
|
|
|
@ -36,10 +36,12 @@ import org.apache.http.Header;
|
||||||
import org.apache.http.HeaderElement;
|
import org.apache.http.HeaderElement;
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
import org.apache.http.HttpRequest;
|
import org.apache.http.HttpRequest;
|
||||||
|
import org.apache.http.annotation.Immutable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public class URIExtractor {
|
public class URIExtractor {
|
||||||
|
|
||||||
public String getURI(HttpHost host, HttpRequest req) {
|
public String getURI(HttpHost host, HttpRequest req) {
|
||||||
|
|
Loading…
Reference in New Issue