From 877970d7d82d4e5a025de672a8524ed532d1ac60 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Wed, 19 Dec 2012 09:45:50 +0000 Subject: [PATCH] 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 --- .../org/apache/http/impl/client/cache/CacheEntryUpdater.java | 5 +++-- .../org/apache/http/impl/client/cache/ResourceReference.java | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) 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(); }