diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntryUpdater.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntryUpdater.java index 87a8f152a..f1cad47ab 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntryUpdater.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntryUpdater.java @@ -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; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResourceReference.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResourceReference.java index 91e9a0b16..4f9ac4420 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResourceReference.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResourceReference.java @@ -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 { @@ -40,9 +41,7 @@ class ResourceReference extends PhantomReference { public ResourceReference(final HttpCacheEntry entry, final ReferenceQueue 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(); }