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:
parent
b1134f6533
commit
e2da283f21
|
@ -57,9 +57,4 @@ public interface Resource extends Serializable {
|
||||||
*/
|
*/
|
||||||
void dispose();
|
void dispose();
|
||||||
|
|
||||||
/**
|
|
||||||
* Is this resource still valid to be used
|
|
||||||
*/
|
|
||||||
boolean isValid();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,10 +108,7 @@ class CacheValidityPolicy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRevalidatable(final HttpCacheEntry entry) {
|
public boolean isRevalidatable(final HttpCacheEntry entry) {
|
||||||
if (!entry.getResource().isValid())
|
return entry.getFirstHeader(HeaderConstants.ETAG) != null
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return entry.getFirstHeader(HeaderConstants.ETAG) != null
|
|
||||||
|| entry.getFirstHeader(HeaderConstants.LAST_MODIFIED) != null;
|
|| entry.getFirstHeader(HeaderConstants.LAST_MODIFIED) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,9 +130,6 @@ class CachedResponseSuitabilityChecker {
|
||||||
* @return boolean yes/no answer
|
* @return boolean yes/no answer
|
||||||
*/
|
*/
|
||||||
public boolean canCachedResponseBeUsed(HttpHost host, HttpRequest request, HttpCacheEntry entry, Date now) {
|
public boolean canCachedResponseBeUsed(HttpHost host, HttpRequest request, HttpCacheEntry entry, Date now) {
|
||||||
if (!entry.getResource().isValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isFreshEnough(entry, request, now)) {
|
if (!isFreshEnough(entry, request, now)) {
|
||||||
log.trace("Cache entry was not fresh enough");
|
log.trace("Cache entry was not fresh enough");
|
||||||
|
|
|
@ -31,8 +31,6 @@ import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
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.annotation.ThreadSafe;
|
||||||
import org.apache.http.client.cache.Resource;
|
import org.apache.http.client.cache.Resource;
|
||||||
|
|
||||||
|
@ -50,34 +48,21 @@ public class FileResource implements Resource {
|
||||||
|
|
||||||
private volatile boolean disposed;
|
private volatile boolean disposed;
|
||||||
|
|
||||||
private final Log log = LogFactory.getLog(getClass());
|
|
||||||
|
|
||||||
public FileResource(final File file) {
|
public FileResource(final File file) {
|
||||||
super();
|
super();
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.disposed = false;
|
this.disposed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid() {
|
|
||||||
if (this.disposed || !file.exists()) {
|
|
||||||
log.warn("Resource has been deallocated");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized File getFile() {
|
synchronized File getFile() {
|
||||||
isValid();
|
|
||||||
return this.file;
|
return this.file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized InputStream getInputStream() throws IOException {
|
public synchronized InputStream getInputStream() throws IOException {
|
||||||
isValid();
|
|
||||||
return new FileInputStream(this.file);
|
return new FileInputStream(this.file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized long length() {
|
public synchronized long length() {
|
||||||
isValid();
|
|
||||||
return this.file.length();
|
return this.file.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,4 @@ public class HeapResource implements Resource {
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue