hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1423516 [4/4] - in /httpcomponents/httpclient/trunk: httpclient-cache/src/main/java/org/apache/http/client/cache/ httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ httpclient/src/main/java/org/apache/http/auth/ httpclient/s...
Date Tue, 18 Dec 2012 16:23:14 GMT
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java Tue Dec 18 16:22:58 2012
@@ -30,6 +30,7 @@ import java.lang.ref.WeakReference;
 import java.lang.ref.ReferenceQueue;
 
 import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.util.Args;
 
 /**
  * A weak reference to a {@link BasicPoolEntry BasicPoolEntry}.
@@ -56,10 +57,7 @@ public class BasicPoolEntryRef extends W
     public BasicPoolEntryRef(BasicPoolEntry entry,
                              ReferenceQueue<Object> queue) {
         super(entry, queue);
-        if (entry == null) {
-            throw new IllegalArgumentException
-                ("Pool entry must not be null.");
-        }
+        Args.notNull(entry, "Pool entry");
         route = entry.getPlannedRoute();
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java Tue Dec 18 16:22:58 2012
@@ -30,23 +30,25 @@ import java.io.IOException;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Queue;
 import java.util.LinkedList;
 import java.util.Map;
+import java.util.Queue;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.ClientConnectionOperator;
 import org.apache.http.conn.ConnectionPoolTimeoutException;
 import org.apache.http.conn.OperatedClientConnection;
-import org.apache.http.conn.params.ConnPerRoute;
 import org.apache.http.conn.params.ConnManagerParams;
+import org.apache.http.conn.params.ConnPerRoute;
+import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
+import org.apache.http.util.Asserts;
 
 /**
  * A connection pool that maintains connections by route.
@@ -122,12 +124,8 @@ public class ConnPoolByRoute extends Abs
             long connTTL,
             final TimeUnit connTTLTimeUnit) {
         super();
-        if (operator == null) {
-            throw new IllegalArgumentException("Connection operator may not be null");
-        }
-        if (connPerRoute == null) {
-            throw new IllegalArgumentException("Connections per route may not be null");
-        }
+        Args.notNull(operator, "Connection operator");
+        Args.notNull(connPerRoute, "Connections per route");
         this.poolLock = super.poolLock;
         this.leasedConnections = super.leasedConnections;
         this.operator = operator;
@@ -341,10 +339,7 @@ public class ConnPoolByRoute extends Abs
             WaitingThread waitingThread = null;
 
             while (entry == null) {
-
-                if (shutdown) {
-                    throw new IllegalStateException("Connection pool shut down");
-                }
+                Asserts.check(!shutdown, "Connection pool shut down");
 
                 if (log.isDebugEnabled()) {
                     log.debug("[" + route + "] total kept alive: " + freeConnections.size() +
@@ -716,9 +711,7 @@ public class ConnPoolByRoute extends Abs
      */
     @Override
     public void closeIdleConnections(long idletime, TimeUnit tunit) {
-        if (tunit == null) {
-            throw new IllegalArgumentException("Time unit must not be null.");
-        }
+        Args.notNull(tunit, "Time unit");
         if (idletime < 0) {
             idletime = 0;
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java Tue Dec 18 16:22:58 2012
@@ -36,6 +36,8 @@ import org.apache.commons.logging.LogFac
 import org.apache.http.conn.OperatedClientConnection;
 import org.apache.http.conn.params.ConnPerRoute;
 import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.util.Args;
+import org.apache.http.util.Asserts;
 import org.apache.http.util.LangUtils;
 
 
@@ -201,7 +203,6 @@ public class RouteSpecificPool {
      *                  or presented to {@link #createdEntry createdEntry}
      */
     public void freeEntry(BasicPoolEntry entry) {
-
         if (numEntries < 1) {
             throw new IllegalStateException
                 ("No entry created for this pool. " + route);
@@ -223,14 +224,7 @@ public class RouteSpecificPool {
      * @param entry     the entry that was created for this pool
      */
     public void createdEntry(BasicPoolEntry entry) {
-
-        if (!route.equals(entry.getPlannedRoute())) {
-            throw new IllegalArgumentException
-                ("Entry not planned for this pool." +
-                 "\npool: " + route +
-                 "\nplan: " + entry.getPlannedRoute());
-        }
-
+        Args.check(route.equals(entry.getPlannedRoute()), "Entry not planned for this pool");
         numEntries++;
     }
 
@@ -261,10 +255,7 @@ public class RouteSpecificPool {
      * from this pool has been lost and will not be returned.
      */
     public void dropEntry() {
-        if (numEntries < 1) {
-            throw new IllegalStateException
-                ("There is no entry that could be dropped.");
-        }
+        Asserts.check(numEntries > 0, "There is no entry that could be dropped");
         numEntries--;
     }
 
@@ -278,10 +269,7 @@ public class RouteSpecificPool {
      * @param wt        the waiting thread
      */
     public void queueThread(WaitingThread wt) {
-        if (wt == null) {
-            throw new IllegalArgumentException
-                ("Waiting thread must not be null.");
-        }
+        Args.notNull(wt, "Waiting thread");
         this.waitingThreads.add(wt);
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java Tue Dec 18 16:22:58 2012
@@ -32,19 +32,21 @@ import java.util.concurrent.TimeUnit;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.conn.params.ConnPerRouteBean;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.conn.ClientConnectionOperator;
 import org.apache.http.conn.ClientConnectionRequest;
 import org.apache.http.conn.ConnectionPoolTimeoutException;
 import org.apache.http.conn.ManagedClientConnection;
 import org.apache.http.conn.OperatedClientConnection;
-import org.apache.http.params.HttpParams;
+import org.apache.http.conn.params.ConnPerRouteBean;
+import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.impl.conn.DefaultClientConnectionOperator;
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
 import org.apache.http.impl.conn.SchemeRegistryFactory;
+import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
+import org.apache.http.util.Asserts;
 
 /**
  * Manages a pool of {@link OperatedClientConnection client connections} and
@@ -130,9 +132,7 @@ public class ThreadSafeClientConnManager
     public ThreadSafeClientConnManager(final SchemeRegistry schreg,
             long connTTL, TimeUnit connTTLTimeUnit, ConnPerRouteBean connPerRoute) {
         super();
-        if (schreg == null) {
-            throw new IllegalArgumentException("Scheme registry may not be null");
-        }
+        Args.notNull(schreg, "Scheme registry");
         this.log = LogFactory.getLog(getClass());
         this.schemeRegistry = schreg;
         this.connPerRoute = connPerRoute;
@@ -152,9 +152,7 @@ public class ThreadSafeClientConnManager
     @Deprecated
 	public ThreadSafeClientConnManager(HttpParams params,
                                        SchemeRegistry schreg) {
-        if (schreg == null) {
-            throw new IllegalArgumentException("Scheme registry may not be null");
-        }
+        Args.notNull(schreg, "Scheme registry");
         this.log = LogFactory.getLog(getClass());
         this.schemeRegistry = schreg;
         this.connPerRoute = new ConnPerRouteBean();
@@ -233,9 +231,7 @@ public class ThreadSafeClientConnManager
             public ManagedClientConnection getConnection(
                     long timeout, TimeUnit tunit) throws InterruptedException,
                     ConnectionPoolTimeoutException {
-                if (route == null) {
-                    throw new IllegalArgumentException("Route may not be null.");
-                }
+                Args.notNull(route, "Route");
 
                 if (log.isDebugEnabled()) {
                     log.debug("Get connection: " + route + ", timeout = " + timeout);
@@ -250,17 +246,11 @@ public class ThreadSafeClientConnManager
     }
 
     public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
-
-        if (!(conn instanceof BasicPooledConnAdapter)) {
-            throw new IllegalArgumentException
-                ("Connection class mismatch, " +
-                 "connection not obtained from this manager.");
-        }
+        Args.check(conn instanceof BasicPooledConnAdapter, "Connection class mismatch, " +
+                "connection not obtained from this manager");
         BasicPooledConnAdapter hca = (BasicPooledConnAdapter) conn;
-        if ((hca.getPoolEntry() != null) && (hca.getManager() != this)) {
-            throw new IllegalArgumentException
-                ("Connection not obtained from this manager.");
-        }
+        Asserts.check(hca.getPoolEntry() == null, "Connection not obtained from this manager");
+        Asserts.check(hca.getManager() == this, "Connection not obtained from this manager");
         synchronized (hca) {
             BasicPoolEntry entry = (BasicPoolEntry) hca.getPoolEntry();
             if (entry == null) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThread.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThread.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThread.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThread.java Tue Dec 18 16:22:58 2012
@@ -30,6 +30,8 @@ package org.apache.http.impl.conn.tsccm;
 import java.util.Date;
 import java.util.concurrent.locks.Condition;
 
+import org.apache.http.util.Args;
+
 /**
  * Represents a thread waiting for a connection.
  * This class implements throwaway objects. It is instantiated whenever
@@ -71,9 +73,7 @@ public class WaitingThread {
      */
     public WaitingThread(Condition cond, RouteSpecificPool pool) {
 
-        if (cond == null) {
-            throw new IllegalArgumentException("Condition must not be null.");
-        }
+        Args.notNull(cond, "Condition");
 
         this.cond = cond;
         this.pool = pool;

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java Tue Dec 18 16:22:58 2012
@@ -32,9 +32,9 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.http.annotation.NotThreadSafe;
-
 import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieSpec;
+import org.apache.http.util.Args;
 
 /**
  * Abstract cookie specification which can delegate the job of parsing,
@@ -62,12 +62,8 @@ public abstract class AbstractCookieSpec
 
     public void registerAttribHandler(
             final String name, final CookieAttributeHandler handler) {
-        if (name == null) {
-            throw new IllegalArgumentException("Attribute name may not be null");
-        }
-        if (handler == null) {
-            throw new IllegalArgumentException("Attribute handler may not be null");
-        }
+        Args.notNull(name, "Attribute name");
+        Args.notNull(handler, "Attribute handler");
         this.attribHandlerMap.put(name, handler);
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java Tue Dec 18 16:22:58 2012
@@ -34,9 +34,9 @@ import java.util.Locale;
 import java.util.Map;
 
 import org.apache.http.annotation.NotThreadSafe;
-
 import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.SetCookie;
+import org.apache.http.util.Args;
 
 /**
  * Default implementation of {@link SetCookie}.
@@ -56,9 +56,7 @@ public class BasicClientCookie implement
      */
     public BasicClientCookie(final String name, final String value) {
         super();
-        if (name == null) {
-            throw new IllegalArgumentException("Name may not be null");
-        }
+        Args.notNull(name, "Name");
         this.name = name;
         this.attribs = new HashMap<String, String>();
         this.value = value;
@@ -282,9 +280,7 @@ public class BasicClientCookie implement
      * @return <tt>true</tt> if the cookie has expired.
      */
     public boolean isExpired(final Date date) {
-        if (date == null) {
-            throw new IllegalArgumentException("Date may not be null");
-        }
+        Args.notNull(date, "Date");
         return (cookieExpiryDate != null
             && cookieExpiryDate.getTime() <= date.getTime());
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicCommentHandler.java Tue Dec 18 16:22:58 2012
@@ -27,9 +27,9 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
-
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
+import org.apache.http.util.Args;
 
 /**
  *
@@ -44,9 +44,7 @@ public class BasicCommentHandler extends
 
     public void parse(final SetCookie cookie, final String value)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         cookie.setComment(value);
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java Tue Dec 18 16:22:58 2012
@@ -27,13 +27,13 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
-
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
+import org.apache.http.util.Args;
 
 /**
  *
@@ -48,9 +48,7 @@ public class BasicDomainHandler implemen
 
     public void parse(final SetCookie cookie, final String value)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         if (value == null) {
             throw new MalformedCookieException("Missing value for domain attribute");
         }
@@ -62,12 +60,8 @@ public class BasicDomainHandler implemen
 
     public void validate(final Cookie cookie, final CookieOrigin origin)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         // Validate the cookies domain attribute.  NOTE:  Domains without
         // any dots are allowed to support hosts on private LANs that don't
         // have DNS names.  Since they have no dots, to domain-match the
@@ -103,12 +97,8 @@ public class BasicDomainHandler implemen
     }
 
     public boolean match(final Cookie cookie, final CookieOrigin origin) {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         String host = origin.getHost();
         String domain = cookie.getDomain();
         if (domain == null) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java Tue Dec 18 16:22:58 2012
@@ -27,9 +27,9 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
-
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
+import org.apache.http.util.Args;
 
 
 /**
@@ -43,17 +43,13 @@ public class BasicExpiresHandler extends
     private final String[] datepatterns;
 
     public BasicExpiresHandler(final String[] datepatterns) {
-        if (datepatterns == null) {
-            throw new IllegalArgumentException("Array of date patterns may not be null");
-        }
+        Args.notNull(datepatterns, "Array of date patterns");
         this.datepatterns = datepatterns;
     }
 
     public void parse(final SetCookie cookie, final String value)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         if (value == null) {
             throw new MalformedCookieException("Missing value for expires attribute");
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java Tue Dec 18 16:22:58 2012
@@ -29,9 +29,9 @@ package org.apache.http.impl.cookie;
 import java.util.Date;
 
 import org.apache.http.annotation.Immutable;
-
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
+import org.apache.http.util.Args;
 
 /**
  *
@@ -46,9 +46,7 @@ public class BasicMaxAgeHandler extends 
 
     public void parse(final SetCookie cookie, final String value)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         if (value == null) {
             throw new MalformedCookieException("Missing value for max-age attribute");
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java Tue Dec 18 16:22:58 2012
@@ -27,13 +27,13 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
-
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
+import org.apache.http.util.Args;
 
 /**
  *
@@ -48,9 +48,7 @@ public class BasicPathHandler implements
 
     public void parse(final SetCookie cookie, String value)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         if (value == null || value.trim().length() == 0) {
             value = "/";
         }
@@ -67,12 +65,8 @@ public class BasicPathHandler implements
     }
 
     public boolean match(final Cookie cookie, final CookieOrigin origin) {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         String targetpath = origin.getPath();
         String topmostPath = cookie.getPath();
         if (topmostPath == null) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java Tue Dec 18 16:22:58 2012
@@ -27,11 +27,11 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
-
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
+import org.apache.http.util.Args;
 
 /**
  *
@@ -46,20 +46,14 @@ public class BasicSecureHandler extends 
 
     public void parse(final SetCookie cookie, final String value)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         cookie.setSecure(true);
     }
 
     @Override
     public boolean match(final Cookie cookie, final CookieOrigin origin) {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         return !cookie.isSecure() || origin.isSecure();
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java Tue Dec 18 16:22:58 2012
@@ -29,11 +29,10 @@ package org.apache.http.impl.cookie;
 
 import java.util.List;
 
-import org.apache.http.annotation.NotThreadSafe;
-
 import org.apache.http.FormattedHeader;
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
+import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieSpec;
@@ -41,6 +40,7 @@ import org.apache.http.cookie.MalformedC
 import org.apache.http.cookie.SM;
 import org.apache.http.cookie.SetCookie2;
 import org.apache.http.message.ParserCursor;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -94,12 +94,8 @@ public class BestMatchSpec implements Co
     public List<Cookie> parse(
             final Header header,
             final CookieOrigin origin) throws MalformedCookieException {
-        if (header == null) {
-            throw new IllegalArgumentException("Header may not be null");
-        }
-        if (origin == null) {
-           throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(header, "Header");
+        Args.notNull(origin, "Cookie origin");
         HeaderElement[] helems = header.getElements();
         boolean versioned = false;
         boolean netscape = false;
@@ -145,12 +141,8 @@ public class BestMatchSpec implements Co
     public void validate(
             final Cookie cookie,
             final CookieOrigin origin) throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         if (cookie.getVersion() > 0) {
             if (cookie instanceof SetCookie2) {
                 getStrict().validate(cookie, origin);
@@ -163,12 +155,8 @@ public class BestMatchSpec implements Co
     }
 
     public boolean match(final Cookie cookie, final CookieOrigin origin) {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         if (cookie.getVersion() > 0) {
             if (cookie instanceof SetCookie2) {
                 return getStrict().match(cookie, origin);
@@ -181,9 +169,7 @@ public class BestMatchSpec implements Co
     }
 
     public List<Header> formatCookies(final List<Cookie> cookies) {
-        if (cookies == null) {
-            throw new IllegalArgumentException("List of cookies may not be null");
-        }
+        Args.notNull(cookies, "List of cookies");
         int version = Integer.MAX_VALUE;
         boolean isSetCookie2 = true;
         for (Cookie cookie: cookies) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java Tue Dec 18 16:22:58 2012
@@ -30,11 +30,10 @@ package org.apache.http.impl.cookie;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.http.annotation.NotThreadSafe;
-
 import org.apache.http.FormattedHeader;
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
+import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
@@ -44,6 +43,7 @@ import org.apache.http.message.BasicHead
 import org.apache.http.message.BasicHeaderValueFormatter;
 import org.apache.http.message.BufferedHeader;
 import org.apache.http.message.ParserCursor;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -101,12 +101,8 @@ public class BrowserCompatSpec extends C
 
     public List<Cookie> parse(final Header header, final CookieOrigin origin)
             throws MalformedCookieException {
-        if (header == null) {
-            throw new IllegalArgumentException("Header may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(header, "Header");
+        Args.notNull(origin, "Cookie origin");
         String headername = header.getName();
         if (!headername.equalsIgnoreCase(SM.SET_COOKIE)) {
             throw new MalformedCookieException("Unrecognized cookie header '"
@@ -149,12 +145,7 @@ public class BrowserCompatSpec extends C
     }
 
     public List<Header> formatCookies(final List<Cookie> cookies) {
-        if (cookies == null) {
-            throw new IllegalArgumentException("List of cookies may not be null");
-        }
-        if (cookies.isEmpty()) {
-            throw new IllegalArgumentException("List of cookies may not be empty");
-        }
+        Args.notEmpty(cookies, "List of cookies");
         CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
         buffer.append(SM.COOKIE);
         buffer.append(": ");

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java Tue Dec 18 16:22:58 2012
@@ -30,6 +30,7 @@ package org.apache.http.impl.cookie;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
+import org.apache.http.util.Args;
 
 /**
  * <tt>"Version"</tt> cookie attribute handler for BrowserCompat cookie spec.
@@ -49,9 +50,7 @@ public class BrowserCompatVersionAttribu
 	 */
 	public void parse(final SetCookie cookie, final String value)
 			throws MalformedCookieException {
-		if (cookie == null) {
-			throw new IllegalArgumentException("Cookie may not be null");
-		}
+		Args.notNull(cookie, "Cookie");
 		if (value == null) {
 			throw new MalformedCookieException("Missing value for version attribute");
 		}

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java Tue Dec 18 16:22:58 2012
@@ -31,14 +31,14 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 
-import org.apache.http.annotation.NotThreadSafe;
-
 import org.apache.http.HeaderElement;
 import org.apache.http.NameValuePair;
+import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.MalformedCookieException;
+import org.apache.http.util.Args;
 
 /**
  * Cookie management functions shared by all specification.
@@ -100,24 +100,16 @@ public abstract class CookieSpecBase ext
 
     public void validate(final Cookie cookie, final CookieOrigin origin)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         for (CookieAttributeHandler handler: getAttribHandlers()) {
             handler.validate(cookie, origin);
         }
     }
 
     public boolean match(final Cookie cookie, final CookieOrigin origin) {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         for (CookieAttributeHandler handler: getAttribHandlers()) {
             if (!handler.match(cookie, origin)) {
                 return false;

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java Tue Dec 18 16:22:58 2012
@@ -39,6 +39,7 @@ import java.util.Map;
 import java.util.TimeZone;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 
 /**
  * A utility class for parsing and formatting HTTP dates as used in cookies and
@@ -134,10 +135,7 @@ public final class DateUtils {
         String[] dateFormats,
         Date startDate
     ) throws DateParseException {
-
-        if (dateValue == null) {
-            throw new IllegalArgumentException("dateValue is null");
-        }
+        Args.notNull(dateValue, "Date value");
         if (dateFormats == null) {
             dateFormats = DEFAULT_PATTERNS;
         }
@@ -192,9 +190,8 @@ public final class DateUtils {
      * @see SimpleDateFormat
      */
     public static String formatDate(Date date, String pattern) {
-        if (date == null) throw new IllegalArgumentException("date is null");
-        if (pattern == null) throw new IllegalArgumentException("pattern is null");
-
+        Args.notNull(date, "Date");
+        Args.notNull(pattern, "Pattern");
         SimpleDateFormat formatter = DateFormatHolder.formatFor(pattern);
         return formatter.format(date);
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java Tue Dec 18 16:22:58 2012
@@ -30,11 +30,11 @@ import java.util.Locale;
 import java.util.StringTokenizer;
 
 import org.apache.http.annotation.Immutable;
-
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
+import org.apache.http.util.Args;
 
 /**
  *
@@ -93,12 +93,8 @@ public class NetscapeDomainHandler exten
 
    @Override
    public boolean match(Cookie cookie, CookieOrigin origin) {
-       if (cookie == null) {
-           throw new IllegalArgumentException("Cookie may not be null");
-       }
-       if (origin == null) {
-           throw new IllegalArgumentException("Cookie origin may not be null");
-       }
+       Args.notNull(cookie, "Cookie");
+       Args.notNull(origin, "Cookie origin");
        String host = origin.getHost();
        String domain = cookie.getDomain();
        if (domain == null) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftHeaderParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftHeaderParser.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftHeaderParser.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftHeaderParser.java Tue Dec 18 16:22:58 2012
@@ -30,15 +30,15 @@ package org.apache.http.impl.cookie;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.http.annotation.Immutable;
-
 import org.apache.http.HeaderElement;
 import org.apache.http.NameValuePair;
 import org.apache.http.ParseException;
+import org.apache.http.annotation.Immutable;
 import org.apache.http.message.BasicHeaderElement;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.message.ParserCursor;
 import org.apache.http.protocol.HTTP;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -57,12 +57,8 @@ public class NetscapeDraftHeaderParser {
     public HeaderElement parseHeader(
             final CharArrayBuffer buffer,
             final ParserCursor cursor) throws ParseException {
-        if (buffer == null) {
-            throw new IllegalArgumentException("Char array buffer may not be null");
-        }
-        if (cursor == null) {
-            throw new IllegalArgumentException("Parser cursor may not be null");
-        }
+        Args.notNull(buffer, "Char array buffer");
+        Args.notNull(cursor, "Parser cursor");
         NameValuePair nvp = parseNameValuePair(buffer, cursor);
         List<NameValuePair> params = new ArrayList<NameValuePair>();
         while (!cursor.atEnd()) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java Tue Dec 18 16:22:58 2012
@@ -30,11 +30,10 @@ package org.apache.http.impl.cookie;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.http.annotation.NotThreadSafe;
-
 import org.apache.http.FormattedHeader;
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
+import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
@@ -43,6 +42,7 @@ import org.apache.http.cookie.MalformedC
 import org.apache.http.cookie.SM;
 import org.apache.http.message.BufferedHeader;
 import org.apache.http.message.ParserCursor;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -107,12 +107,8 @@ public class NetscapeDraftSpec extends C
       */
     public List<Cookie> parse(final Header header, final CookieOrigin origin)
             throws MalformedCookieException {
-        if (header == null) {
-            throw new IllegalArgumentException("Header may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(header, "Header");
+        Args.notNull(origin, "Cookie origin");
         if (!header.getName().equalsIgnoreCase(SM.SET_COOKIE)) {
             throw new MalformedCookieException("Unrecognized cookie header '"
                     + header.toString() + "'");
@@ -138,12 +134,7 @@ public class NetscapeDraftSpec extends C
     }
 
     public List<Header> formatCookies(final List<Cookie> cookies) {
-        if (cookies == null) {
-            throw new IllegalArgumentException("List of cookies may not be null");
-        }
-        if (cookies.isEmpty()) {
-            throw new IllegalArgumentException("List of cookies may not be empty");
-        }
+        Args.notEmpty(cookies, "List of cookies");
         CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
         buffer.append(SM.COOKIE);
         buffer.append(": ");

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java Tue Dec 18 16:22:58 2012
@@ -29,13 +29,13 @@ package org.apache.http.impl.cookie;
 import java.util.Locale;
 
 import org.apache.http.annotation.Immutable;
-
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
+import org.apache.http.util.Args;
 
 /**
  *
@@ -50,9 +50,7 @@ public class RFC2109DomainHandler implem
 
     public void parse(final SetCookie cookie, final String value)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         if (value == null) {
             throw new MalformedCookieException("Missing value for domain attribute");
         }
@@ -64,12 +62,8 @@ public class RFC2109DomainHandler implem
 
     public void validate(final Cookie cookie, final CookieOrigin origin)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         String host = origin.getHost();
         String domain = cookie.getDomain();
         if (domain == null) {
@@ -113,12 +107,8 @@ public class RFC2109DomainHandler implem
     }
 
     public boolean match(final Cookie cookie, final CookieOrigin origin) {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         String host = origin.getHost();
         String domain = cookie.getDomain();
         if (domain == null) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java Tue Dec 18 16:22:58 2012
@@ -31,10 +31,9 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.http.annotation.NotThreadSafe;
-
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
+import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
@@ -44,6 +43,7 @@ import org.apache.http.cookie.CookieSpec
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SM;
 import org.apache.http.message.BufferedHeader;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -95,12 +95,8 @@ public class RFC2109Spec extends CookieS
 
     public List<Cookie> parse(final Header header, final CookieOrigin origin)
             throws MalformedCookieException {
-        if (header == null) {
-            throw new IllegalArgumentException("Header may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(header, "Header");
+        Args.notNull(origin, "Cookie origin");
         if (!header.getName().equalsIgnoreCase(SM.SET_COOKIE)) {
             throw new MalformedCookieException("Unrecognized cookie header '"
                     + header.toString() + "'");
@@ -112,9 +108,7 @@ public class RFC2109Spec extends CookieS
     @Override
     public void validate(final Cookie cookie, final CookieOrigin origin)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         String name = cookie.getName();
         if (name.indexOf(' ') != -1) {
             throw new CookieRestrictionViolationException("Cookie name may not contain blanks");
@@ -126,12 +120,7 @@ public class RFC2109Spec extends CookieS
     }
 
     public List<Header> formatCookies(List<Cookie> cookies) {
-        if (cookies == null) {
-            throw new IllegalArgumentException("List of cookies may not be null");
-        }
-        if (cookies.isEmpty()) {
-            throw new IllegalArgumentException("List of cookies may not be empty");
-        }
+        Args.notEmpty(cookies, "List of cookies");
         if (cookies.size() > 1) {
             // Create a mutable copy and sort the copy.
             cookies = new ArrayList<Cookie>(cookies);

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java Tue Dec 18 16:22:58 2012
@@ -27,12 +27,12 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
-
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
+import org.apache.http.util.Args;
 
 /**
  *
@@ -47,9 +47,7 @@ public class RFC2109VersionHandler exten
 
     public void parse(final SetCookie cookie, final String value)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         if (value == null) {
             throw new MalformedCookieException("Missing value for version attribute");
         }
@@ -67,9 +65,7 @@ public class RFC2109VersionHandler exten
     @Override
     public void validate(final Cookie cookie, final CookieOrigin origin)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         if (cookie.getVersion() < 0) {
             throw new CookieRestrictionViolationException("Cookie version may not be negative");
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java Tue Dec 18 16:22:58 2012
@@ -30,7 +30,6 @@ package org.apache.http.impl.cookie;
 import java.util.Locale;
 
 import org.apache.http.annotation.Immutable;
-
 import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieAttributeHandler;
@@ -38,6 +37,7 @@ import org.apache.http.cookie.CookieOrig
 import org.apache.http.cookie.CookieRestrictionViolationException;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
+import org.apache.http.util.Args;
 
 /**
  * <tt>"Domain"</tt> cookie attribute handler for RFC 2965 cookie spec.
@@ -57,9 +57,7 @@ public class RFC2965DomainAttributeHandl
      */
     public void parse(final SetCookie cookie, String domain)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         if (domain == null) {
             throw new MalformedCookieException(
                     "Missing value for domain attribute");
@@ -107,12 +105,8 @@ public class RFC2965DomainAttributeHandl
      */
     public void validate(final Cookie cookie, final CookieOrigin origin)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         String host = origin.getHost().toLowerCase(Locale.ENGLISH);
         if (cookie.getDomain() == null) {
             throw new CookieRestrictionViolationException("Invalid cookie state: " +
@@ -171,12 +165,8 @@ public class RFC2965DomainAttributeHandl
      * Match cookie domain attribute.
      */
     public boolean match(final Cookie cookie, final CookieOrigin origin) {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         String host = origin.getHost().toLowerCase(Locale.ENGLISH);
         String cookieDomain = cookie.getDomain();
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965PortAttributeHandler.java Tue Dec 18 16:22:58 2012
@@ -30,7 +30,6 @@ package org.apache.http.impl.cookie;
 import java.util.StringTokenizer;
 
 import org.apache.http.annotation.Immutable;
-
 import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieAttributeHandler;
@@ -39,6 +38,7 @@ import org.apache.http.cookie.CookieRest
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
 import org.apache.http.cookie.SetCookie2;
+import org.apache.http.util.Args;
 
 /**
  * <tt>"Port"</tt> cookie attribute handler for RFC 2965 cookie spec.
@@ -106,9 +106,7 @@ public class RFC2965PortAttributeHandler
      */
     public void parse(final SetCookie cookie, final String portValue)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         if (cookie instanceof SetCookie2) {
             SetCookie2 cookie2 = (SetCookie2) cookie;
             if (portValue != null && portValue.trim().length() > 0) {
@@ -124,12 +122,8 @@ public class RFC2965PortAttributeHandler
      */
     public void validate(final Cookie cookie, final CookieOrigin origin)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         int port = origin.getPort();
         if (cookie instanceof ClientCookie
                 && ((ClientCookie) cookie).containsAttribute(ClientCookie.PORT_ATTR)) {
@@ -147,12 +141,8 @@ public class RFC2965PortAttributeHandler
      * must be in the cookie's port list.
      */
     public boolean match(final Cookie cookie, final CookieOrigin origin) {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         int port = origin.getPort();
         if (cookie instanceof ClientCookie
                 && ((ClientCookie) cookie).containsAttribute(ClientCookie.PORT_ATTR)) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java Tue Dec 18 16:22:58 2012
@@ -32,11 +32,10 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
-import org.apache.http.annotation.NotThreadSafe;
-
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
 import org.apache.http.NameValuePair;
+import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieAttributeHandler;
@@ -45,6 +44,7 @@ import org.apache.http.cookie.CookieSpec
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SM;
 import org.apache.http.message.BufferedHeader;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -76,12 +76,8 @@ public class RFC2965Spec extends RFC2109
     public List<Cookie> parse(
             final Header header,
             CookieOrigin origin) throws MalformedCookieException {
-        if (header == null) {
-            throw new IllegalArgumentException("Header may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(header, "Header");
+        Args.notNull(origin, "Cookie origin");
         if (!header.getName().equalsIgnoreCase(SM.SET_COOKIE2)) {
             throw new MalformedCookieException("Unrecognized cookie header '"
                     + header.toString() + "'");
@@ -144,24 +140,16 @@ public class RFC2965Spec extends RFC2109
     @Override
     public void validate(final Cookie cookie, CookieOrigin origin)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         origin = adjustEffectiveHost(origin);
         super.validate(cookie, origin);
     }
 
     @Override
     public boolean match(final Cookie cookie, CookieOrigin origin) {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
-        if (origin == null) {
-            throw new IllegalArgumentException("Cookie origin may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
+        Args.notNull(origin, "Cookie origin");
         origin = adjustEffectiveHost(origin);
         return super.match(cookie, origin);
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965VersionAttributeHandler.java Tue Dec 18 16:22:58 2012
@@ -28,7 +28,6 @@
 package org.apache.http.impl.cookie;
 
 import org.apache.http.annotation.Immutable;
-
 import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieAttributeHandler;
@@ -37,6 +36,7 @@ import org.apache.http.cookie.CookieRest
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SetCookie;
 import org.apache.http.cookie.SetCookie2;
+import org.apache.http.util.Args;
 
 /**
  * <tt>"Version"</tt> cookie attribute handler for RFC 2965 cookie spec.
@@ -55,9 +55,7 @@ public class RFC2965VersionAttributeHand
      */
     public void parse(final SetCookie cookie, final String value)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         if (value == null) {
             throw new MalformedCookieException(
                     "Missing value for version attribute");
@@ -79,9 +77,7 @@ public class RFC2965VersionAttributeHand
      */
     public void validate(final Cookie cookie, final CookieOrigin origin)
             throws MalformedCookieException {
-        if (cookie == null) {
-            throw new IllegalArgumentException("Cookie may not be null");
-        }
+        Args.notNull(cookie, "Cookie");
         if (cookie instanceof SetCookie2) {
             if (cookie instanceof ClientCookie
                     && !((ClientCookie) cookie).containsAttribute(ClientCookie.VERSION_ATTR)) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java Tue Dec 18 16:22:58 2012
@@ -68,30 +68,14 @@ public final class MockConnPoolControl i
     }
 
     public void setDefaultMaxPerRoute(int max) {
-        if (max < 1) {
-            throw new IllegalArgumentException
-                ("The maximum must be greater than 0.");
-        }
         this.defaultMax = max;
     }
 
     public void setMaxPerRoute(final HttpRoute route, int max) {
-        if (route == null) {
-            throw new IllegalArgumentException
-                ("HTTP route may not be null.");
-        }
-        if (max < 1) {
-            throw new IllegalArgumentException
-                ("The maximum must be greater than 0.");
-        }
         this.maxPerHostMap.put(route, Integer.valueOf(max));
     }
 
     public int getMaxPerRoute(final HttpRoute route) {
-        if (route == null) {
-            throw new IllegalArgumentException
-                ("HTTP route may not be null.");
-        }
         Integer max = this.maxPerHostMap.get(route);
         if (max != null) {
             return max.intValue();

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java Tue Dec 18 16:22:58 2012
@@ -212,7 +212,7 @@ public class TestBasicHttpClientConnecti
         mgr.releaseConnection(null, null, 0, TimeUnit.MILLISECONDS);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=IllegalStateException.class)
     public void testReleaseAnotherConnection() throws Exception {
         HttpClientConnection wrongCon = Mockito.mock(HttpClientConnection.class);
         mgr.releaseConnection(wrongCon, null, 0, TimeUnit.MILLISECONDS);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java Tue Dec 18 16:22:58 2012
@@ -198,7 +198,7 @@ public class TestHttpClientConnectionOpe
         Mockito.verify(conn).bind(socket);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=IllegalStateException.class)
     public void testUpgradeNonLayeringScheme() throws Exception {
         HttpContext context = new BasicHttpContext();
         HttpHost host = new HttpHost("somehost", -1, "http");

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java Tue Dec 18 16:22:58 2012
@@ -58,6 +58,7 @@ import org.apache.http.protocol.Response
 import org.apache.http.protocol.ResponseDate;
 import org.apache.http.protocol.ResponseServer;
 import org.apache.http.protocol.UriHttpRequestHandlerMapper;
+import org.apache.http.util.Asserts;
 
 /**
  * Local HTTP server for tests that require one.
@@ -224,9 +225,7 @@ public class LocalTestServer {
      * Starts this test server.
      */
     public void start() throws Exception {
-        if (servicedSocket != null) {
-            throw new IllegalStateException(this.toString() + " already running");
-        }
+        Asserts.check(servicedSocket == null, "Already running");
         ServerSocket ssock;
         if (sslcontext != null) {
             SSLServerSocketFactory sf = sslcontext.getServerSocketFactory();
@@ -287,9 +286,7 @@ public class LocalTestServer {
      */
     public InetSocketAddress getServiceAddress() {
         ServerSocket ssock = servicedSocket; // avoid synchronization
-        if (ssock == null) {
-            throw new IllegalStateException("not running");
-        }
+        Asserts.check(ssock != null, "Not running");
         return (InetSocketAddress) ssock.getLocalSocketAddress();
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/RandomHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/RandomHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/RandomHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/RandomHandler.java Tue Dec 18 16:22:58 2012
@@ -155,13 +155,6 @@ public class RandomHandler
          *              0 to maxint
          */
         public RandomEntity(long len) {
-            if (len < 0L)
-                throw new IllegalArgumentException
-                    ("Length must not be negative");
-            if (len > Integer.MAX_VALUE)
-                throw new IllegalArgumentException
-                    ("Length must not exceed Integer.MAX_VALUE");
-
             length = len;
         }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/mockup/SocketFactoryMockup.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/mockup/SocketFactoryMockup.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/mockup/SocketFactoryMockup.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/mockup/SocketFactoryMockup.java Tue Dec 18 16:22:58 2012
@@ -73,7 +73,7 @@ public class SocketFactoryMockup impleme
 
     public boolean isSecure(Socket sock) {
         // no way that the argument is from *this* factory...
-        throw new IllegalArgumentException("I'm a mockup!");
+        throw new UnsupportedOperationException("I'm a mockup!");
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java Tue Dec 18 16:22:58 2012
@@ -28,6 +28,7 @@
 package org.apache.http.entity.mime;
 
 import org.apache.http.entity.mime.content.ContentBody;
+import org.apache.http.util.Args;
 
 /**
  * FormBodyPart class represents a content body that can be used as a part of multipart encoded
@@ -45,12 +46,8 @@ public class FormBodyPart {
 
     public FormBodyPart(final String name, final ContentBody body) {
         super();
-        if (name == null) {
-            throw new IllegalArgumentException("Name may not be null");
-        }
-        if (body == null) {
-            throw new IllegalArgumentException("Body may not be null");
-        }
+        Args.notNull(name, "Name");
+        Args.notNull(body, "Body");
         this.name = name;
         this.body = body;
         this.header = new Header();
@@ -73,9 +70,7 @@ public class FormBodyPart {
     }
 
     public void addField(final String name, final String value) {
-        if (name == null) {
-            throw new IllegalArgumentException("Field name may not be null");
-        }
+        Args.notNull(name, "Field name");
         this.header.addField(new MinimalField(name, value));
     }
 

Modified: httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/HttpMultipart.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/HttpMultipart.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/HttpMultipart.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/HttpMultipart.java Tue Dec 18 16:22:58 2012
@@ -37,6 +37,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.http.entity.mime.content.ContentBody;
+import org.apache.http.util.Args;
 import org.apache.http.util.ByteArrayBuffer;
 
 /**
@@ -112,12 +113,8 @@ public class HttpMultipart {
      */
     public HttpMultipart(final String subType, final Charset charset, final String boundary, HttpMultipartMode mode) {
         super();
-        if (subType == null) {
-            throw new IllegalArgumentException("Multipart subtype may not be null");
-        }
-        if (boundary == null) {
-            throw new IllegalArgumentException("Multipart boundary may not be null");
-        }
+        Args.notNull(subType, "Multipart subtype");
+        Args.notNull(boundary, "Multipart boundary");
         this.subType = subType;
         this.charset = charset != null ? charset : MIME.DEFAULT_CHARSET;
         this.boundary = boundary;

Modified: httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntityBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntityBuilder.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntityBuilder.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntityBuilder.java Tue Dec 18 16:22:58 2012
@@ -38,6 +38,7 @@ import org.apache.http.entity.mime.conte
 import org.apache.http.entity.mime.content.FileBody;
 import org.apache.http.entity.mime.content.InputStreamBody;
 import org.apache.http.entity.mime.content.StringBody;
+import org.apache.http.util.Args;
 
 /**
  * @since 4.3
@@ -79,12 +80,8 @@ public class MultipartEntityBuilder {
 
     public MultipartEntityBuilder addTextBody(
             final String name, final String text, final ContentType contentType) {
-        if (name == null) {
-            throw new IllegalArgumentException("Name may not be null");
-        }
-        if (text == null) {
-            throw new IllegalArgumentException("Text may not be null");
-        }
+        Args.notNull(name, "Name");
+        Args.notNull(text, "Text");
         if (this.bodyParts == null) {
             this.bodyParts = new ArrayList<FormBodyPart>();
         }

Modified: httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/AbstractContentBody.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/AbstractContentBody.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/AbstractContentBody.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/AbstractContentBody.java Tue Dec 18 16:22:58 2012
@@ -30,6 +30,7 @@ package org.apache.http.entity.mime.cont
 import java.nio.charset.Charset;
 
 import org.apache.http.entity.ContentType;
+import org.apache.http.util.Args;
 
 /**
  *
@@ -44,9 +45,7 @@ public abstract class AbstractContentBod
      */
     public AbstractContentBody(final ContentType contentType) {
         super();
-        if (contentType == null) {
-            throw new IllegalArgumentException("Content type may not be null");
-        }
+        Args.notNull(contentType, "Content type");
         this.contentType = contentType;
     }
 

Modified: httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java Tue Dec 18 16:22:58 2012
@@ -32,7 +32,7 @@ import java.io.OutputStream;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.mime.MIME;
 import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.entity.mime.content.AbstractContentBody;
+import org.apache.http.util.Args;
 
 /**
  * Binary body part backed by a byte array.
@@ -72,9 +72,7 @@ public class ByteArrayBody extends Abstr
      */
     public ByteArrayBody(final byte[] data, final ContentType contentType, final String filename) {
         super(contentType);
-        if (data == null) {
-            throw new IllegalArgumentException("byte[] may not be null");
-        }
+        Args.notNull(data, "byte[]");
         this.data = data;
         this.filename = filename;
     }

Modified: httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java Tue Dec 18 16:22:58 2012
@@ -36,6 +36,7 @@ import java.io.OutputStream;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.mime.MIME;
 import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.util.Args;
 
 /**
  * Binary body part backed by a file.
@@ -94,9 +95,7 @@ public class FileBody extends AbstractCo
      */
     public FileBody(final File file, final ContentType contentType, final String filename) {
         super(contentType);
-        if (file == null) {
-            throw new IllegalArgumentException("File may not be null");
-        }
+        Args.notNull(file, "File");
         this.file = file;
         this.filename = filename;
     }
@@ -113,9 +112,7 @@ public class FileBody extends AbstractCo
     }
 
     public void writeTo(final OutputStream out) throws IOException {
-        if (out == null) {
-            throw new IllegalArgumentException("Output stream may not be null");
-        }
+        Args.notNull(out, "Output stream");
         InputStream in = new FileInputStream(this.file);
         try {
             byte[] tmp = new byte[4096];

Modified: httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java Tue Dec 18 16:22:58 2012
@@ -34,6 +34,7 @@ import java.io.OutputStream;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.mime.MIME;
 import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.util.Args;
 
 /**
  * Binary body part backed by an input stream.
@@ -66,9 +67,7 @@ public class InputStreamBody extends Abs
      */
     public InputStreamBody(final InputStream in, final ContentType contentType, final String filename) {
         super(contentType);
-        if (in == null) {
-            throw new IllegalArgumentException("Input stream may not be null");
-        }
+        Args.notNull(in, "Input stream");
         this.in = in;
         this.filename = filename;
     }
@@ -85,9 +84,7 @@ public class InputStreamBody extends Abs
     }
 
     public void writeTo(final OutputStream out) throws IOException {
-        if (out == null) {
-            throw new IllegalArgumentException("Output stream may not be null");
-        }
+        Args.notNull(out, "Output stream");
         try {
             byte[] tmp = new byte[4096];
             int l;

Modified: httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java Tue Dec 18 16:22:58 2012
@@ -41,6 +41,7 @@ import org.apache.http.Consts;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.mime.MIME;
 import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.util.Args;
 
 /**
  * Text body part backed by a byte array.
@@ -171,9 +172,7 @@ public class StringBody extends Abstract
     }
 
     public void writeTo(final OutputStream out) throws IOException {
-        if (out == null) {
-            throw new IllegalArgumentException("Output stream may not be null");
-        }
+        Args.notNull(out, "Output stream");
         InputStream in = new ByteArrayInputStream(this.content);
         byte[] tmp = new byte[4096];
         int l;



Mime
View raw message