From 16a8c311001a6104e02f1c4e7f4175b93d5fb958 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Fri, 30 Apr 2010 23:29:15 +0000 Subject: [PATCH] CachingHttpClient(HttpCache cache, int maxObjectSizeBytes) failed to save maxObjectSizeBytes Make all immutable private fields final git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@939875 13f79535-47bb-0310-9956-ffa450edef68 --- .../client/cache/impl/CachingHttpClient.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/CachingHttpClient.java b/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/CachingHttpClient.java index 88be45268..df963af01 100644 --- a/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/CachingHttpClient.java +++ b/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/CachingHttpClient.java @@ -60,6 +60,7 @@ import org.apache.http.protocol.HttpContext; */ public class CachingHttpClient implements HttpClient { + private static final Log LOG = LogFactory.getLog(CachingHttpClient.class); private final static int MAX_CACHE_ENTRIES = 1000; private final static int DEFAULT_MAX_OBJECT_SIZE_BYTES = 8192; @@ -67,29 +68,29 @@ public class CachingHttpClient implements HttpClient { private final static boolean SUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS = false; - private HttpClient backend; - private ResponseCachingPolicy responseCachingPolicy; - private CacheEntryGenerator cacheEntryGenerator; - private URIExtractor uriExtractor; - private HttpCache responseCache; - private CachedHttpResponseGenerator responseGenerator; - private CacheInvalidator cacheInvalidator; - private CacheableRequestPolicy cacheableRequestPolicy; - private CachedResponseSuitabilityChecker suitabilityChecker; + private final HttpClient backend; + private final ResponseCachingPolicy responseCachingPolicy; + private final CacheEntryGenerator cacheEntryGenerator; + private final URIExtractor uriExtractor; + private final HttpCache responseCache; + private final CachedHttpResponseGenerator responseGenerator; + private final CacheInvalidator cacheInvalidator; + private final CacheableRequestPolicy cacheableRequestPolicy; + private final CachedResponseSuitabilityChecker suitabilityChecker; - private ConditionalRequestBuilder conditionalRequestBuilder; - private int maxObjectSizeBytes = DEFAULT_MAX_OBJECT_SIZE_BYTES; - private CacheEntryUpdater cacheEntryUpdater; + private final ConditionalRequestBuilder conditionalRequestBuilder; + private final int maxObjectSizeBytes; + private final CacheEntryUpdater cacheEntryUpdater; private volatile long cacheHits; private volatile long cacheMisses; private volatile long cacheUpdates; - private ResponseProtocolCompliance responseCompliance; - private RequestProtocolCompliance requestCompliance; - private static final Log LOG = LogFactory.getLog(CachingHttpClient.class); + private final ResponseProtocolCompliance responseCompliance; + private final RequestProtocolCompliance requestCompliance; public CachingHttpClient() { this.backend = new DefaultHttpClient(); + this.maxObjectSizeBytes = DEFAULT_MAX_OBJECT_SIZE_BYTES; this.responseCachingPolicy = new ResponseCachingPolicy(maxObjectSizeBytes); this.cacheEntryGenerator = new CacheEntryGenerator(); this.uriExtractor = new URIExtractor(); @@ -108,6 +109,7 @@ public class CachingHttpClient implements HttpClient { this.responseCache = cache; this.backend = new DefaultHttpClient(); + this.maxObjectSizeBytes = maxObjectSizeBytes; this.responseCachingPolicy = new ResponseCachingPolicy(maxObjectSizeBytes); this.cacheEntryGenerator = new CacheEntryGenerator(); this.uriExtractor = new URIExtractor(); @@ -147,6 +149,7 @@ public class CachingHttpClient implements HttpClient { ConditionalRequestBuilder conditionalRequestBuilder, CacheEntryUpdater entryUpdater, ResponseProtocolCompliance responseCompliance, RequestProtocolCompliance requestCompliance) { + this.maxObjectSizeBytes = DEFAULT_MAX_OBJECT_SIZE_BYTES; this.backend = backend; this.responseCachingPolicy = responseCachingPolicy; this.cacheEntryGenerator = cacheEntryGenerator;