Use Asserts to verify object state (follow-up)

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1423806 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2012-12-19 09:45:50 +00:00
parent d72e9b3ae7
commit 877970d7d8
2 changed files with 5 additions and 5 deletions

View File

@ -44,6 +44,7 @@ import org.apache.http.client.cache.ResourceFactory;
import org.apache.http.impl.cookie.DateParseException;
import org.apache.http.impl.cookie.DateUtils;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.Args;
/**
* Update a {@link HttpCacheEntry} with new or updated information based on the latest
@ -84,8 +85,8 @@ class CacheEntryUpdater {
Date requestDate,
Date responseDate,
HttpResponse response) throws IOException {
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NOT_MODIFIED)
throw new IllegalArgumentException("Response must have 304 status code");
Args.check(response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_MODIFIED,
"Response must have 304 status code");
Header[] mergedHeaders = mergeHeaders(entry, response);
Resource oldResource = entry.getResource();
Resource resource = null;

View File

@ -32,6 +32,7 @@ import java.lang.ref.ReferenceQueue;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.Resource;
import org.apache.http.util.Args;
@Immutable
class ResourceReference extends PhantomReference<HttpCacheEntry> {
@ -40,9 +41,7 @@ class ResourceReference extends PhantomReference<HttpCacheEntry> {
public ResourceReference(final HttpCacheEntry entry, final ReferenceQueue<HttpCacheEntry> q) {
super(entry, q);
if (entry.getResource() == null) {
throw new IllegalArgumentException("Resource may not be null");
}
Args.notNull(entry.getResource(), "Resource");
this.resource = entry.getResource();
}