From e2da283f21949b4812106d16cf0cb88370f9f4b4 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Thu, 2 Feb 2012 11:12:11 +0000 Subject: [PATCH] HTTPCLIENT-1147: backed out API breaking changes git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1239536 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/http/client/cache/Resource.java | 5 ----- .../impl/client/cache/CacheValidityPolicy.java | 5 +---- .../cache/CachedResponseSuitabilityChecker.java | 3 --- .../http/impl/client/cache/FileResource.java | 15 --------------- .../http/impl/client/cache/HeapResource.java | 4 ---- 5 files changed, 1 insertion(+), 31 deletions(-) diff --git a/httpclient-cache/src/main/java/org/apache/http/client/cache/Resource.java b/httpclient-cache/src/main/java/org/apache/http/client/cache/Resource.java index 80c661176..56e14db43 100644 --- a/httpclient-cache/src/main/java/org/apache/http/client/cache/Resource.java +++ b/httpclient-cache/src/main/java/org/apache/http/client/cache/Resource.java @@ -57,9 +57,4 @@ public interface Resource extends Serializable { */ void dispose(); - /** - * Is this resource still valid to be used - */ - boolean isValid(); - } 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 b5802ce0c..c87c7df8b 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 @@ -108,10 +108,7 @@ class CacheValidityPolicy { } public boolean isRevalidatable(final HttpCacheEntry entry) { - if (!entry.getResource().isValid()) - return false; - else - return entry.getFirstHeader(HeaderConstants.ETAG) != null + return entry.getFirstHeader(HeaderConstants.ETAG) != null || entry.getFirstHeader(HeaderConstants.LAST_MODIFIED) != null; } 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 592f7c9aa..439f3df34 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 @@ -130,9 +130,6 @@ class CachedResponseSuitabilityChecker { * @return boolean yes/no answer */ public boolean canCachedResponseBeUsed(HttpHost host, HttpRequest request, HttpCacheEntry entry, Date now) { - if (!entry.getResource().isValid()) { - return false; - } if (!isFreshEnough(entry, request, now)) { log.trace("Cache entry was not fresh enough"); 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 3159d5497..03e2d5f66 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,8 +31,6 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.http.annotation.ThreadSafe; import org.apache.http.client.cache.Resource; @@ -50,34 +48,21 @@ public class FileResource implements Resource { private volatile boolean disposed; - private final Log log = LogFactory.getLog(getClass()); - public FileResource(final File file) { super(); this.file = file; this.disposed = false; } - public boolean isValid() { - if (this.disposed || !file.exists()) { - log.warn("Resource has been deallocated"); - return false; - } - return true; - } - synchronized File getFile() { - isValid(); return this.file; } public synchronized InputStream getInputStream() throws IOException { - isValid(); return new FileInputStream(this.file); } public synchronized long length() { - isValid(); return this.file.length(); } 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 0827df946..181d1cef5 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 @@ -64,8 +64,4 @@ public class HeapResource implements Resource { public void dispose() { } - public boolean isValid() { - return true; - } - }