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
This commit is contained in:
Oleg Kalnichevski 2012-02-02 11:12:11 +00:00
parent b1134f6533
commit e2da283f21
5 changed files with 1 additions and 31 deletions

View File

@ -57,9 +57,4 @@ public interface Resource extends Serializable {
*/
void dispose();
/**
* Is this resource still valid to be used
*/
boolean isValid();
}

View File

@ -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;
}

View File

@ -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");

View File

@ -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();
}

View File

@ -64,8 +64,4 @@ public class HeapResource implements Resource {
public void dispose() {
}
public boolean isValid() {
return true;
}
}