From 529a3e67fcc9ebe92fbc9509a56cb20c01c59bf5 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Fri, 30 Apr 2010 22:18:38 +0000 Subject: [PATCH] Make private immutable variables final git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@939845 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/http/client/cache/impl/BasicHttpCache.java | 7 ++++--- .../apache/http/client/cache/impl/CacheInvalidator.java | 4 ++-- .../apache/http/client/cache/impl/CombinedInputStream.java | 4 ++-- .../http/client/cache/impl/ResponseCachingPolicy.java | 2 +- .../http/client/cache/impl/SizeLimitedResponseReader.java | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/BasicHttpCache.java b/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/BasicHttpCache.java index 96ff98b43..2ab7217bd 100644 --- a/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/BasicHttpCache.java +++ b/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/BasicHttpCache.java @@ -41,19 +41,20 @@ import org.apache.http.client.cache.HttpCache; */ public class BasicHttpCache implements HttpCache { - private LinkedHashMap baseMap = new LinkedHashMap(20, + private final LinkedHashMap baseMap = new LinkedHashMap(20, 0.75f, true) { private static final long serialVersionUID = -7750025207539768511L; + @Override protected boolean removeEldestEntry(Map.Entry eldest) { return size() > maxEntries; } }; - private Map syncMap; + private final Map syncMap; - private int maxEntries; + private final int maxEntries; public BasicHttpCache(int maxEntries) { this.maxEntries = maxEntries; diff --git a/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/CacheInvalidator.java b/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/CacheInvalidator.java index 848645110..28b7b2459 100644 --- a/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/CacheInvalidator.java +++ b/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/CacheInvalidator.java @@ -43,8 +43,8 @@ import org.apache.http.client.cache.HttpCache; */ public class CacheInvalidator { - private HttpCache cache; - private URIExtractor uriExtractor; + private final HttpCache cache; + private final URIExtractor uriExtractor; private static final Log LOG = LogFactory.getLog(CacheInvalidator.class); diff --git a/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/CombinedInputStream.java b/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/CombinedInputStream.java index 6a3990f07..1ac882480 100644 --- a/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/CombinedInputStream.java +++ b/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/CombinedInputStream.java @@ -36,8 +36,8 @@ import java.io.InputStream; */ class CombinedInputStream extends InputStream { - private InputStream inputStream1; - private InputStream inputStream2; + private final InputStream inputStream1; + private final InputStream inputStream2; /** * diff --git a/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/ResponseCachingPolicy.java b/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/ResponseCachingPolicy.java index 0d5b2abff..88cd12307 100644 --- a/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/ResponseCachingPolicy.java +++ b/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/ResponseCachingPolicy.java @@ -43,7 +43,7 @@ import org.apache.http.impl.cookie.DateUtils; */ public class ResponseCachingPolicy { - private int maxObjectSizeBytes; + private final int maxObjectSizeBytes; private static final Log LOG = LogFactory.getLog(ResponseCachingPolicy.class); public ResponseCachingPolicy(int maxObjectSizeBytes) { diff --git a/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/SizeLimitedResponseReader.java b/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/SizeLimitedResponseReader.java index cc4ff735a..5d4282b0a 100644 --- a/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/SizeLimitedResponseReader.java +++ b/httpclient-cache/src/main/java/org/apache/http/client/cache/impl/SizeLimitedResponseReader.java @@ -42,8 +42,8 @@ import org.apache.http.message.BasicHttpResponse; */ public class SizeLimitedResponseReader { - private int maxResponseSizeBytes; - private HttpResponse response; + private final int maxResponseSizeBytes; + private final HttpResponse response; ByteArrayOutputStream outputStream; InputStream contentInputStream;