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

View File

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