hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1423516 [2/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/conn/params/ConnRouteParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParams.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParams.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParams.java Tue Dec 18 16:22:58 2012
@@ -28,12 +28,12 @@ package org.apache.http.conn.params;
 
 import java.net.InetAddress;
 
-import org.apache.http.annotation.Immutable;
-
 import org.apache.http.HttpHost;
-import org.apache.http.params.HttpParams;
+import org.apache.http.annotation.Immutable;
 import org.apache.http.client.config.RequestConfig;
 import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 
 /**
  * An adaptor for manipulating HTTP routing parameters
@@ -78,9 +78,7 @@ public class ConnRouteParams implements 
      *          <code>null</code> if not set
      */
     public static HttpHost getDefaultProxy(HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("Parameters must not be null.");
-        }
+        Args.notNull(params, "Parameters");
         HttpHost proxy = (HttpHost)
             params.getParameter(DEFAULT_PROXY);
         if ((proxy != null) && NO_HOST.equals(proxy)) {
@@ -102,9 +100,7 @@ public class ConnRouteParams implements 
      */
     public static void setDefaultProxy(HttpParams params,
                                              HttpHost proxy) {
-        if (params == null) {
-            throw new IllegalArgumentException("Parameters must not be null.");
-        }
+        Args.notNull(params, "Parameters");
         params.setParameter(DEFAULT_PROXY, proxy);
     }
 
@@ -120,9 +116,7 @@ public class ConnRouteParams implements 
      *          <code>null</code> if not set
      */
     public static HttpRoute getForcedRoute(HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("Parameters must not be null.");
-        }
+        Args.notNull(params, "Parameters");
         HttpRoute route = (HttpRoute)
             params.getParameter(FORCED_ROUTE);
         if ((route != null) && NO_ROUTE.equals(route)) {
@@ -144,9 +138,7 @@ public class ConnRouteParams implements 
      */
     public static void setForcedRoute(HttpParams params,
                                             HttpRoute route) {
-        if (params == null) {
-            throw new IllegalArgumentException("Parameters must not be null.");
-        }
+        Args.notNull(params, "Parameters");
         params.setParameter(FORCED_ROUTE, route);
     }
 
@@ -163,9 +155,7 @@ public class ConnRouteParams implements 
      *          <code>null</code> if not set
      */
     public static InetAddress getLocalAddress(HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("Parameters must not be null.");
-        }
+        Args.notNull(params, "Parameters");
         InetAddress local = (InetAddress)
             params.getParameter(LOCAL_ADDRESS);
         // no explicit unsetting
@@ -181,9 +171,7 @@ public class ConnRouteParams implements 
      */
     public static void setLocalAddress(HttpParams params,
                                              InetAddress local) {
-        if (params == null) {
-            throw new IllegalArgumentException("Parameters must not be null.");
-        }
+        Args.notNull(params, "Parameters");
         params.setParameter(LOCAL_ADDRESS, local);
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java Tue Dec 18 16:22:58 2012
@@ -28,6 +28,7 @@
 package org.apache.http.conn.routing;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 
 /**
  * Basic implementation of an {@link HttpRouteDirector HttpRouteDirector}.
@@ -50,10 +51,7 @@ public class BasicRouteDirector implemen
      *          0 is for success, a negative value for failure.
      */
     public int nextStep(RouteInfo plan, RouteInfo fact) {
-        if (plan == null) {
-            throw new IllegalArgumentException
-                ("Planned route may not be null.");
-        }
+        Args.notNull(plan, "Planned route");
 
         int step = UNREACHABLE;
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java Tue Dec 18 16:22:58 2012
@@ -30,6 +30,7 @@ package org.apache.http.conn.routing;
 import java.net.InetAddress;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 import org.apache.http.util.LangUtils;
 
 import org.apache.http.HttpHost;
@@ -92,19 +93,14 @@ public final class HttpRoute implements 
                       HttpHost target, HttpHost[] proxies,
                       boolean secure,
                       TunnelType tunnelled, LayerType layered) {
-        if (target == null) {
-            throw new IllegalArgumentException
-                ("Target host may not be null.");
+        Args.notNull(target, "Target host");
+        Args.notNull(proxies, "Array of proxy hosts");
+        for (HttpHost proxy: proxies) {
+            Args.notNull(proxy, "Proxy host");
         }
-        if (proxies == null) {
-            throw new IllegalArgumentException
-                ("Proxies may not be null.");
+        if (tunnelled == TunnelType.TUNNELLED) {
+            Args.check(proxies.length > 0, "Proxy required if tunnelled");
         }
-        if ((tunnelled == TunnelType.TUNNELLED) && (proxies.length == 0)) {
-            throw new IllegalArgumentException
-                ("Proxy required if tunnelled.");
-        }
-
         // tunnelled is already checked above, that is in line with the default
         if (tunnelled == null)
             tunnelled = TunnelType.PLAIN;
@@ -205,10 +201,7 @@ public final class HttpRoute implements 
         this(local, target, toChain(proxy), secure,
              secure ? TunnelType.TUNNELLED : TunnelType.PLAIN,
              secure ? LayerType.LAYERED    : LayerType.PLAIN);
-        if (proxy == null) {
-            throw new IllegalArgumentException
-                ("Proxy host may not be null.");
-        }
+        Args.notNull(proxy, "Proxy host");
     }
 
 
@@ -238,13 +231,6 @@ public final class HttpRoute implements 
     private static HttpHost[] toChain(HttpHost[] proxies) {
         if ((proxies == null) || (proxies.length < 1))
             return EMPTY_HTTP_HOST_ARRAY;
-
-        for (HttpHost proxy : proxies) {
-            if (proxy == null)
-                throw new IllegalArgumentException
-                        ("Proxy chain may not contain null elements.");
-        }
-
         // copy the proxy chain, the traditional way
         HttpHost[] result = new HttpHost[proxies.length];
         System.arraycopy(proxies, 0, result, 0, proxies.length);
@@ -272,14 +258,9 @@ public final class HttpRoute implements 
 
 
     public final HttpHost getHopTarget(int hop) {
-        if (hop < 0)
-            throw new IllegalArgumentException
-                ("Hop index must not be negative: " + hop);
+        Args.notNegative(hop, "Hop index");
         final int hopcount = getHopCount();
-        if (hop >= hopcount)
-            throw new IllegalArgumentException
-                ("Hop index " + hop +
-                 " exceeds route length " + hopcount);
+        Args.check(hop < hopcount, "Hop index exceeds tracked route length");
 
         HttpHost result = null;
         if (hop < hopcount-1)

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java Tue Dec 18 16:22:58 2012
@@ -30,6 +30,8 @@ package org.apache.http.conn.routing;
 import java.net.InetAddress;
 
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
+import org.apache.http.util.Asserts;
 import org.apache.http.util.LangUtils;
 
 import org.apache.http.HttpHost;
@@ -78,9 +80,7 @@ public final class RouteTracker implemen
      *                  <code>null</code> for the default
      */
     public RouteTracker(HttpHost target, InetAddress local) {
-        if (target == null) {
-            throw new IllegalArgumentException("Target host may not be null.");
-        }
+        Args.notNull(target, "Target host");
         this.targetHost   = target;
         this.localAddress = local;
         this.tunnelled    = TunnelType.PLAIN;
@@ -116,9 +116,7 @@ public final class RouteTracker implemen
      *                  <code>false</code> otherwise
      */
     public final void connectTarget(boolean secure) {
-        if (this.connected) {
-            throw new IllegalStateException("Already connected.");
-        }
+        Asserts.check(!this.connected, "Already connected");
         this.connected = true;
         this.secure = secure;
     }
@@ -131,12 +129,8 @@ public final class RouteTracker implemen
      *                  <code>false</code> otherwise
      */
     public final void connectProxy(HttpHost proxy, boolean secure) {
-        if (proxy == null) {
-            throw new IllegalArgumentException("Proxy host may not be null.");
-        }
-        if (this.connected) {
-            throw new IllegalStateException("Already connected.");
-        }
+        Args.notNull(proxy, "Proxy host");
+        Asserts.check(!this.connected, "Already connected");
         this.connected  = true;
         this.proxyChain = new HttpHost[]{ proxy };
         this.secure     = secure;
@@ -149,12 +143,8 @@ public final class RouteTracker implemen
      *                  <code>false</code> otherwise
      */
     public final void tunnelTarget(boolean secure) {
-        if (!this.connected) {
-            throw new IllegalStateException("No tunnel unless connected.");
-        }
-        if (this.proxyChain == null) {
-            throw new IllegalStateException("No tunnel without proxy.");
-        }
+        Asserts.check(this.connected, "No tunnel unless connected");
+        Asserts.notNull(this.proxyChain, "No tunnel without proxy");
         this.tunnelled = TunnelType.TUNNELLED;
         this.secure    = secure;
     }
@@ -169,16 +159,9 @@ public final class RouteTracker implemen
      *                  <code>false</code> otherwise
      */
     public final void tunnelProxy(HttpHost proxy, boolean secure) {
-        if (proxy == null) {
-            throw new IllegalArgumentException("Proxy host may not be null.");
-        }
-        if (!this.connected) {
-            throw new IllegalStateException("No tunnel unless connected.");
-        }
-        if (this.proxyChain == null) {
-            throw new IllegalStateException("No proxy tunnel without proxy.");
-        }
-
+        Args.notNull(proxy, "Proxy host");
+        Asserts.check(this.connected, "No tunnel unless connected");
+        Asserts.notNull(this.proxyChain, "No tunnel without proxy");
         // prepare an extended proxy chain
         HttpHost[] proxies = new HttpHost[this.proxyChain.length+1];
         System.arraycopy(this.proxyChain, 0,
@@ -198,10 +181,7 @@ public final class RouteTracker implemen
     public final void layerProtocol(boolean secure) {
         // it is possible to layer a protocol over a direct connection,
         // although this case is probably not considered elsewhere
-        if (!this.connected) {
-            throw new IllegalStateException
-                ("No layered protocol unless connected.");
-        }
+        Asserts.check(this.connected, "No layered protocol unless connected");
         this.layered = LayerType.LAYERED;
         this.secure  = secure;
     }
@@ -226,16 +206,9 @@ public final class RouteTracker implemen
     }
 
     public final HttpHost getHopTarget(int hop) {
-        if (hop < 0)
-            throw new IllegalArgumentException
-                ("Hop index must not be negative: " + hop);
+        Args.notNegative(hop, "Hop index");
         final int hopcount = getHopCount();
-        if (hop >= hopcount) {
-            throw new IllegalArgumentException
-                ("Hop index " + hop +
-                 " exceeds tracked route length " + hopcount +".");
-        }
-
+        Args.check(hop < hopcount, "Hop index exceeds tracked route length");
         HttpHost result = null;
         if (hop < hopcount-1)
             result = this.proxyChain[hop];

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java Tue Dec 18 16:22:58 2012
@@ -35,11 +35,11 @@ import java.net.SocketTimeoutException;
 import java.net.UnknownHostException;
 
 import org.apache.http.annotation.Immutable;
-
 import org.apache.http.conn.ConnectTimeoutException;
 import org.apache.http.conn.DnsResolver;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 
 /**
  * The default class for creating plain (unencrypted) sockets.
@@ -100,12 +100,8 @@ public class PlainSocketFactory implemen
             final InetSocketAddress remoteAddress,
             final InetSocketAddress localAddress,
             final HttpParams params) throws IOException, ConnectTimeoutException {
-        if (remoteAddress == null) {
-            throw new IllegalArgumentException("Remote address may not be null");
-        }
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(remoteAddress, "Remote address");
+        Args.notNull(params, "HTTP parameters");
         Socket sock = socket;
         if (sock == null) {
             sock = createSocket();
@@ -134,15 +130,8 @@ public class PlainSocketFactory implemen
      * @param sock      the connected socket
      *
      * @return  <code>false</code>
-     *
-     * @throws IllegalArgumentException if the argument is invalid
      */
-    public final boolean isSecure(Socket sock)
-        throws IllegalArgumentException {
-
-        if (sock == null) {
-            throw new IllegalArgumentException("Socket may not be null.");
-        }
+    public final boolean isSecure(Socket sock) {
         return false;
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java Tue Dec 18 16:22:58 2012
@@ -31,7 +31,7 @@ import java.util.Locale;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.config.Registry;
 import org.apache.http.conn.SchemePortResolver;
-
+import org.apache.http.util.Args;
 import org.apache.http.util.LangUtils;
 
 /**
@@ -89,15 +89,9 @@ public final class Scheme {
      * @since 4.1
      */
     public Scheme(final String name, final int port, final SchemeSocketFactory factory) {
-        if (name == null) {
-            throw new IllegalArgumentException("Scheme name may not be null");
-        }
-        if ((port <= 0) || (port > 0xffff)) {
-            throw new IllegalArgumentException("Port is invalid: " + port);
-        }
-        if (factory == null) {
-            throw new IllegalArgumentException("Socket factory may not be null");
-        }
+        Args.notNull(name, "Scheme name");
+        Args.check(port > 0 && port <= 0xffff, "Port is invalid");
+        Args.notNull(factory, "Socket factory");
         this.name = name.toLowerCase(Locale.ENGLISH);
         this.defaultPort = port;
         if (factory instanceof SchemeLayeredSocketFactory) {
@@ -130,18 +124,9 @@ public final class Scheme {
                   final SocketFactory factory,
                   final int port) {
 
-        if (name == null) {
-            throw new IllegalArgumentException
-                ("Scheme name may not be null");
-        }
-        if (factory == null) {
-            throw new IllegalArgumentException
-                ("Socket factory may not be null");
-        }
-        if ((port <= 0) || (port > 0xffff)) {
-            throw new IllegalArgumentException
-                ("Port is invalid: " + port);
-        }
+        Args.notNull(name, "Scheme name");
+        Args.notNull(factory, "Socket factory");
+        Args.check(port > 0 && port <= 0xffff, "Port is invalid");
 
         this.name = name.toLowerCase(Locale.ENGLISH);
         if (factory instanceof LayeredSocketFactory) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeRegistry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeRegistry.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeRegistry.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeRegistry.java Tue Dec 18 16:22:58 2012
@@ -31,10 +31,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.http.HttpHost;
 import org.apache.http.annotation.ThreadSafe;
 import org.apache.http.config.Registry;
-
-import org.apache.http.HttpHost;
+import org.apache.http.util.Args;
 
 /**
  * A set of supported protocol {@link Scheme}s.
@@ -90,9 +90,7 @@ public final class SchemeRegistry {
      *          if a scheme with the respective name is not registered
      */
     public final Scheme getScheme(HttpHost host) {
-        if (host == null) {
-            throw new IllegalArgumentException("Host must not be null.");
-        }
+        Args.notNull(host, "Host");
         return getScheme(host.getSchemeName());
     }
 
@@ -105,9 +103,7 @@ public final class SchemeRegistry {
      *          <code>null</code> if there is none by this name
      */
     public final Scheme get(String name) {
-        if (name == null)
-            throw new IllegalArgumentException("Name must not be null.");
-
+        Args.notNull(name, "Scheme name");
         // leave it to the caller to use the correct name - all lowercase
         //name = name.toLowerCase();
         Scheme found = registeredSchemes.get(name);
@@ -125,9 +121,7 @@ public final class SchemeRegistry {
      *          <code>null</code> if none was registered
      */
     public final Scheme register(Scheme sch) {
-        if (sch == null)
-            throw new IllegalArgumentException("Scheme must not be null.");
-
+        Args.notNull(sch, "Scheme");
         Scheme old = registeredSchemes.put(sch.getName(), sch);
         return old;
     }
@@ -141,9 +135,7 @@ public final class SchemeRegistry {
      *          <code>null</code> if there was none
      */
     public final Scheme unregister(String name) {
-        if (name == null)
-            throw new IllegalArgumentException("Name must not be null.");
-
+        Args.notNull(name, "Scheme name");
         // leave it to the caller to use the correct name - all lowercase
         //name = name.toLowerCase();
         Scheme gone = registeredSchemes.remove(name);

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java Tue Dec 18 16:22:58 2012
@@ -27,29 +27,6 @@
 
 package org.apache.http.conn.ssl;
 
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.ThreadSafe;
-
-import org.apache.http.config.SocketConfig;
-import org.apache.http.conn.ConnectTimeoutException;
-import org.apache.http.conn.HttpInetSocketAddress;
-import org.apache.http.conn.scheme.HostNameResolver;
-import org.apache.http.conn.scheme.LayeredSchemeSocketFactory;
-import org.apache.http.conn.scheme.LayeredSocketFactory;
-import org.apache.http.conn.scheme.SchemeLayeredSocketFactory;
-import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HttpContext;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-import javax.net.ssl.X509TrustManager;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -67,6 +44,30 @@ import java.security.SecureRandom;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.CertificateException;
 
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.http.HttpHost;
+import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.config.SocketConfig;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.conn.HttpInetSocketAddress;
+import org.apache.http.conn.scheme.HostNameResolver;
+import org.apache.http.conn.scheme.LayeredSchemeSocketFactory;
+import org.apache.http.conn.scheme.LayeredSocketFactory;
+import org.apache.http.conn.scheme.SchemeLayeredSocketFactory;
+import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
+import org.apache.http.util.Asserts;
+
 /**
  * Layered socket factory for TLS/SSL connections.
  * <p>
@@ -477,9 +478,7 @@ public class SSLSocketFactory implements
     public SSLSocketFactory(
             final SSLContext sslContext, final X509HostnameVerifier hostnameVerifier) {
         super();
-        if (sslContext == null) {
-            throw new IllegalArgumentException("SSL context may not be null");
-        }
+        Args.notNull(sslContext, "SSL context");
         this.socketfactory = sslContext.getSocketFactory();
         this.hostnameVerifier = hostnameVerifier;
         this.nameResolver = null;
@@ -491,9 +490,7 @@ public class SSLSocketFactory implements
     public SSLSocketFactory(
             final javax.net.ssl.SSLSocketFactory socketfactory,
             final X509HostnameVerifier hostnameVerifier) {
-        if (socketfactory == null) {
-            throw new IllegalArgumentException("SSL socket factory may not be null");
-        }
+        Args.notNull(socketfactory, "SSL socket factory");
         this.socketfactory = socketfactory;
         this.hostnameVerifier = hostnameVerifier;
         this.nameResolver = null;
@@ -531,12 +528,8 @@ public class SSLSocketFactory implements
             final InetSocketAddress remoteAddress,
             final InetSocketAddress localAddress,
             final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
-        if (remoteAddress == null) {
-            throw new IllegalArgumentException("Remote address may not be null");
-        }
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(remoteAddress, "Remote address");
+        Args.notNull(params, "HTTP parameters");
         HttpHost host;
         if (remoteAddress instanceof HttpInetSocketAddress) {
             host = ((HttpInetSocketAddress) remoteAddress).getHttpHost();
@@ -565,17 +558,9 @@ public class SSLSocketFactory implements
      */
     @Deprecated
     public boolean isSecure(final Socket sock) throws IllegalArgumentException {
-        if (sock == null) {
-            throw new IllegalArgumentException("Socket may not be null");
-        }
-        // This instanceof check is in line with createSocket() above.
-        if (!(sock instanceof SSLSocket)) {
-            throw new IllegalArgumentException("Socket not created by this factory");
-        }
-        // This check is performed last since it calls the argument object.
-        if (sock.isClosed()) {
-            throw new IllegalArgumentException("Socket is closed");
-        }
+        Args.notNull(sock, "Socket");
+        Asserts.check(sock instanceof SSLSocket, "Socket not created by this factory");
+        Asserts.check(!sock.isClosed(), "Socket is closed");
         return true;
     }
 
@@ -610,9 +595,7 @@ public class SSLSocketFactory implements
      */
     @Deprecated
     public void setHostnameVerifier(X509HostnameVerifier hostnameVerifier) {
-        if ( hostnameVerifier == null ) {
-            throw new IllegalArgumentException("Hostname verifier may not be null");
-        }
+        Args.notNull(hostnameVerifier, "Hostname verifier");
         this.hostnameVerifier = hostnameVerifier;
     }
 
@@ -695,12 +678,8 @@ public class SSLSocketFactory implements
             final InetSocketAddress remoteAddress,
             final InetSocketAddress localAddress,
             final HttpContext context) throws IOException, ConnectTimeoutException {
-        if (host == null) {
-            throw new IllegalArgumentException("HTTP host may not be null");
-        }
-        if (remoteAddress == null) {
-            throw new IllegalArgumentException("Remote address may not be null");
-        }
+        Args.notNull(host, "HTTP host");
+        Args.notNull(remoteAddress, "Remote address");
         Socket sock = socket != null ? socket : createSocket(context);
         if (localAddress != null) {
             sock.bind(localAddress);

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java Tue Dec 18 16:22:58 2012
@@ -29,6 +29,7 @@ package org.apache.http.cookie;
 import java.util.Locale;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 
 /**
  * CookieOrigin class encapsulates details of an origin server that
@@ -46,21 +47,9 @@ public final class CookieOrigin {
 
     public CookieOrigin(final String host, int port, final String path, boolean secure) {
         super();
-        if (host == null) {
-            throw new IllegalArgumentException(
-                    "Host of origin may not be null");
-        }
-        if (host.trim().length() == 0) {
-            throw new IllegalArgumentException(
-                    "Host of origin may not be blank");
-        }
-        if (port < 0) {
-            throw new IllegalArgumentException("Invalid port: " + port);
-        }
-        if (path == null) {
-            throw new IllegalArgumentException(
-                    "Path of origin may not be null.");
-        }
+        Args.notBlank(host, "Host");
+        Args.notNegative(port, "Port");
+        Args.notNull(path, "Path");
         this.host = host.toLowerCase(Locale.ENGLISH);
         this.port = port;
         if (path.trim().length() != 0) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java Tue Dec 18 16:22:58 2012
@@ -40,6 +40,7 @@ import org.apache.http.config.Registry;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 
 /**
  * Cookie specification registry that can be used to obtain the corresponding
@@ -73,12 +74,8 @@ public final class CookieSpecRegistry im
      * @see #getCookieSpec(String)
      */
     public void register(final String name, final CookieSpecFactory factory) {
-         if (name == null) {
-             throw new IllegalArgumentException("Name may not be null");
-         }
-        if (factory == null) {
-            throw new IllegalArgumentException("Cookie spec factory may not be null");
-        }
+         Args.notNull(name, "Name");
+        Args.notNull(factory, "Cookie spec factory");
         registeredSpecs.put(name.toLowerCase(Locale.ENGLISH), factory);
     }
 
@@ -88,9 +85,7 @@ public final class CookieSpecRegistry im
      * @param id the identifier of the {@link CookieSpec cookie specification} to unregister
      */
     public void unregister(final String id) {
-         if (id == null) {
-             throw new IllegalArgumentException("Id may not be null");
-         }
+         Args.notNull(id, "Id");
          registeredSpecs.remove(id.toLowerCase(Locale.ENGLISH));
     }
 
@@ -108,9 +103,7 @@ public final class CookieSpecRegistry im
     public CookieSpec getCookieSpec(final String name, final HttpParams params)
         throws IllegalStateException {
 
-        if (name == null) {
-            throw new IllegalArgumentException("Name may not be null");
-        }
+        Args.notNull(name, "Name");
         CookieSpecFactory factory = registeredSpecs.get(name.toLowerCase(Locale.ENGLISH));
         if (factory != null) {
             return factory.newInstance(params);

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java Tue Dec 18 16:22:58 2012
@@ -28,11 +28,10 @@ package org.apache.http.impl.auth;
 
 import java.util.Locale;
 
-import org.apache.http.annotation.NotThreadSafe;
-
 import org.apache.http.FormattedHeader;
 import org.apache.http.Header;
 import org.apache.http.HttpRequest;
+import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.auth.AUTH;
 import org.apache.http.auth.AuthenticationException;
 import org.apache.http.auth.ChallengeState;
@@ -41,6 +40,7 @@ import org.apache.http.auth.Credentials;
 import org.apache.http.auth.MalformedChallengeException;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -86,9 +86,7 @@ public abstract class AuthSchemeBase imp
      * is malformed
      */
     public void processChallenge(final Header header) throws MalformedChallengeException {
-        if (header == null) {
-            throw new IllegalArgumentException("Header may not be null");
-        }
+        Args.notNull(header, "Header");
         String authheader = header.getName();
         if (authheader.equalsIgnoreCase(AUTH.WWW_AUTH)) {
             this.challengeState = ChallengeState.TARGET;

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java Tue Dec 18 16:22:58 2012
@@ -28,22 +28,22 @@ package org.apache.http.impl.auth;
 
 import java.nio.charset.Charset;
 
-import org.apache.http.annotation.NotThreadSafe;
-
 import org.apache.commons.codec.binary.Base64;
 import org.apache.http.Consts;
 import org.apache.http.Header;
 import org.apache.http.HttpRequest;
+import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.auth.AUTH;
 import org.apache.http.auth.AuthenticationException;
 import org.apache.http.auth.ChallengeState;
 import org.apache.http.auth.ContextAwareAuthScheme;
 import org.apache.http.auth.Credentials;
-import org.apache.http.auth.AUTH;
 import org.apache.http.auth.InvalidCredentialsException;
 import org.apache.http.auth.MalformedChallengeException;
 import org.apache.http.message.BufferedHeader;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 import org.apache.http.util.EncodingUtils;
 
@@ -153,12 +153,8 @@ public class BasicScheme extends RFC2617
             final HttpRequest request,
             final HttpContext context) throws AuthenticationException {
 
-        if (credentials == null) {
-            throw new IllegalArgumentException("Credentials may not be null");
-        }
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
+        Args.notNull(credentials, "Credentials");
+        Args.notNull(request, "HTTP request");
         StringBuilder tmp = new StringBuilder();
         tmp.append(credentials.getUserPrincipal().getName());
         tmp.append(":");
@@ -195,12 +191,8 @@ public class BasicScheme extends RFC2617
             final Credentials credentials,
             final String charset,
             boolean proxy) {
-        if (credentials == null) {
-            throw new IllegalArgumentException("Credentials may not be null");
-        }
-        if (charset == null) {
-            throw new IllegalArgumentException("charset may not be null");
-        }
+        Args.notNull(credentials, "Credentials");
+        Args.notNull(charset, "charset");
 
         StringBuilder tmp = new StringBuilder();
         tmp.append(credentials.getUserPrincipal().getName());

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java Tue Dec 18 16:22:58 2012
@@ -38,24 +38,24 @@ import java.util.Locale;
 import java.util.Set;
 import java.util.StringTokenizer;
 
-import org.apache.http.annotation.NotThreadSafe;
-
 import org.apache.http.Consts;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpRequest;
+import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.auth.AUTH;
 import org.apache.http.auth.AuthenticationException;
 import org.apache.http.auth.ChallengeState;
 import org.apache.http.auth.ContextAwareAuthScheme;
 import org.apache.http.auth.Credentials;
-import org.apache.http.auth.AUTH;
 import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.message.BasicHeaderValueFormatter;
+import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.message.BufferedHeader;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 import org.apache.http.util.EncodingUtils;
 
@@ -206,12 +206,8 @@ public class DigestScheme extends RFC261
             final HttpRequest request,
             final HttpContext context) throws AuthenticationException {
 
-        if (credentials == null) {
-            throw new IllegalArgumentException("Credentials may not be null");
-        }
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
+        Args.notNull(credentials, "Credentials");
+        Args.notNull(request, "HTTP request");
         if (getParameter("realm") == null) {
             throw new AuthenticationException("missing realm in challenge");
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java Tue Dec 18 16:22:58 2012
@@ -40,6 +40,7 @@ import org.apache.http.client.protocol.C
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.message.BasicHeader;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 import org.ietf.jgss.GSSContext;
 import org.ietf.jgss.GSSException;
@@ -122,9 +123,7 @@ public abstract class GGSSchemeBase exte
             final Credentials credentials,
             final HttpRequest request,
             final HttpContext context) throws AuthenticationException {
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
+        Args.notNull(request, "HTTP request");
         switch (state) {
         case UNINITIATED:
             throw new AuthenticationException(getSchemeName() + " authentication has not been initiated");

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java Tue Dec 18 16:22:58 2012
@@ -30,6 +30,7 @@ import org.apache.http.HttpRequest;
 import org.apache.http.auth.AuthenticationException;
 import org.apache.http.auth.Credentials;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 import org.ietf.jgss.GSSException;
 import org.ietf.jgss.Oid;
 
@@ -86,9 +87,7 @@ public class KerberosScheme extends GGSS
      * @return <code>null</code>
      */
     public String getParameter(String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Parameter name may not be null");
-        }
+        Args.notNull(name, "Parameter name");
         return null;
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java Tue Dec 18 16:22:58 2012
@@ -26,18 +26,17 @@
 
 package org.apache.http.impl.auth;
 
-import org.apache.http.annotation.NotThreadSafe;
-
 import org.apache.http.Header;
 import org.apache.http.HttpRequest;
+import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.auth.AUTH;
 import org.apache.http.auth.AuthenticationException;
 import org.apache.http.auth.Credentials;
 import org.apache.http.auth.InvalidCredentialsException;
 import org.apache.http.auth.MalformedChallengeException;
 import org.apache.http.auth.NTCredentials;
-import org.apache.http.impl.auth.AuthSchemeBase;
 import org.apache.http.message.BufferedHeader;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -65,9 +64,7 @@ public class NTLMScheme extends AuthSche
 
     public NTLMScheme(final NTLMEngine engine) {
         super();
-        if (engine == null) {
-            throw new IllegalArgumentException("NTLM engine may not be null");
-        }
+        Args.notNull(engine, "NTLM engine");
         this.engine = engine;
         this.state = State.UNINITIATED;
         this.challenge = null;

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/NegotiateScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/NegotiateScheme.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/NegotiateScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/NegotiateScheme.java Tue Dec 18 16:22:58 2012
@@ -34,6 +34,7 @@ import org.apache.http.HttpRequest;
 import org.apache.http.auth.AuthenticationException;
 import org.apache.http.auth.Credentials;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 import org.ietf.jgss.GSSException;
 import org.ietf.jgss.Oid;
 
@@ -175,9 +176,7 @@ public class NegotiateScheme extends GGS
      * @return the parameter with the given name
      */
     public String getParameter(String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Parameter name may not be null");
-        }
+        Args.notNull(name, "Parameter name");
         return null;
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java Tue Dec 18 16:22:58 2012
@@ -30,6 +30,7 @@ import org.apache.http.HttpRequest;
 import org.apache.http.auth.AuthenticationException;
 import org.apache.http.auth.Credentials;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 import org.ietf.jgss.GSSException;
 import org.ietf.jgss.Oid;
 
@@ -87,9 +88,7 @@ public class SPNegoScheme extends GGSSch
      * @return <code>null</code>
      */
     public String getParameter(String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Parameter name may not be null");
-        }
+        Args.notNull(name, "Parameter name");
         return null;
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java Tue Dec 18 16:22:58 2012
@@ -31,6 +31,7 @@ import java.util.Map;
 import org.apache.http.client.BackoffManager;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.pool.ConnPoolControl;
+import org.apache.http.util.Args;
 
 /**
  * <p>The <code>AIMDBackoffManager</code> applies an additive increase,
@@ -126,9 +127,7 @@ public class AIMDBackoffManager implemen
      * @param d must be between 0.0 and 1.0, exclusive.
      */
     public void setBackoffFactor(double d) {
-        if (d <= 0.0 || d >= 1.0) {
-            throw new IllegalArgumentException("backoffFactor must be 0.0 < f < 1.0");
-        }
+        Args.check(d > 0.0 && d < 1.0, "Backoff factor must be 0.0 < f < 1.0");
         backoffFactor = d;
     }
 
@@ -140,9 +139,7 @@ public class AIMDBackoffManager implemen
      * @param l must be positive
      */
     public void setCooldownMillis(long l) {
-        if (coolDown <= 0) {
-            throw new IllegalArgumentException("cooldownMillis must be positive");
-        }
+        Args.positive(coolDown, "Cool down");
         coolDown = l;
     }
 
@@ -152,9 +149,7 @@ public class AIMDBackoffManager implemen
      * @param cap must be >= 1
      */
     public void setPerHostConnectionCap(int cap) {
-        if (cap < 1) {
-            throw new IllegalArgumentException("perHostConnectionCap must be >= 1");
-        }
+        Args.positive(cap, "Per host connection cap");
         this.cap = cap;
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java Tue Dec 18 16:22:58 2012
@@ -51,6 +51,7 @@ import org.apache.http.client.params.Aut
 import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Asserts;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -142,10 +143,7 @@ public abstract class AbstractAuthentica
 
         AuthSchemeRegistry registry = (AuthSchemeRegistry) context.getAttribute(
                 ClientContext.AUTHSCHEME_REGISTRY);
-        if (registry == null) {
-            throw new IllegalStateException("AuthScheme registry not set in HTTP context");
-        }
-
+        Asserts.notNull(registry, "AuthScheme registry");
         Collection<String> authPrefs = getAuthPreferences(response, context);
         if (authPrefs == null) {
             authPrefs = DEFAULT_SCHEME_PRIORITY;

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java Tue Dec 18 16:22:58 2012
@@ -89,6 +89,7 @@ import org.apache.http.protocol.HttpCont
 import org.apache.http.protocol.HttpProcessor;
 import org.apache.http.protocol.HttpRequestExecutor;
 import org.apache.http.protocol.ImmutableHttpProcessor;
+import org.apache.http.util.Args;
 
 /**
  * Base class for {@link HttpClient} implementations. This class acts as
@@ -780,10 +781,7 @@ public abstract class AbstractHttpClient
                                       HttpContext context)
         throws IOException, ClientProtocolException {
 
-        if (request == null) {
-            throw new IllegalArgumentException
-                ("Request must not be null.");
-        }
+        Args.notNull(request, "HTTP request");
         // a null target may be acceptable, this depends on the route planner
         // a null context is acceptable, default context created below
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyAdaptor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyAdaptor.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyAdaptor.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyAdaptor.java Tue Dec 18 16:22:58 2012
@@ -51,6 +51,7 @@ import org.apache.http.client.Credential
 import org.apache.http.client.params.AuthPolicy;
 import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 
 /**
  * @deprecated (4.2) do not use
@@ -87,18 +88,10 @@ class AuthenticationStrategyAdaptor impl
             final HttpHost authhost,
             final HttpResponse response,
             final HttpContext context) throws MalformedChallengeException {
-        if (challenges == null) {
-            throw new IllegalArgumentException("Map of auth challenges may not be null");
-        }
-        if (authhost == null) {
-            throw new IllegalArgumentException("Host may not be null");
-        }
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
-        if (context == null) {
-            throw new IllegalArgumentException("HTTP context may not be null");
-        }
+        Args.notNull(challenges, "Map of auth challenges");
+        Args.notNull(authhost, "Host");
+        Args.notNull(response, "HTTP response");
+        Args.notNull(context, "HTTP context");
 
         Queue<AuthOption> options = new LinkedList<AuthOption>();
         CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java Tue Dec 18 16:22:58 2012
@@ -59,6 +59,7 @@ import org.apache.http.client.protocol.H
 import org.apache.http.config.Lookup;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 @Immutable
@@ -88,9 +89,7 @@ abstract class AuthenticationStrategyImp
             final HttpHost authhost,
             final HttpResponse response,
             final HttpContext context) {
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
+        Args.notNull(response, "HTTP response");
         int status = response.getStatusLine().getStatusCode();
         return status == this.challengeCode;
     }
@@ -99,9 +98,7 @@ abstract class AuthenticationStrategyImp
             final HttpHost authhost,
             final HttpResponse response,
             final HttpContext context) throws MalformedChallengeException {
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
+        Args.notNull(response, "HTTP response");
         Header[] headers = response.getHeaders(this.headerName);
         Map<String, Header> map = new HashMap<String, Header>(headers.length);
         for (Header header : headers) {
@@ -140,18 +137,10 @@ abstract class AuthenticationStrategyImp
             final HttpHost authhost,
             final HttpResponse response,
             final HttpContext context) throws MalformedChallengeException {
-        if (challenges == null) {
-            throw new IllegalArgumentException("Map of auth challenges may not be null");
-        }
-        if (authhost == null) {
-            throw new IllegalArgumentException("Host may not be null");
-        }
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
-        if (context == null) {
-            throw new IllegalArgumentException("HTTP context may not be null");
-        }
+        Args.notNull(challenges, "Map of auth challenges");
+        Args.notNull(authhost, "Host");
+        Args.notNull(response, "HTTP response");
+        Args.notNull(context, "HTTP context");
         HttpClientContext clientContext = HttpClientContext.adapt(context);
 
         Queue<AuthOption> options = new LinkedList<AuthOption>();
@@ -210,15 +199,9 @@ abstract class AuthenticationStrategyImp
 
     public void authSucceeded(
             final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
-        if (authhost == null) {
-            throw new IllegalArgumentException("Host may not be null");
-        }
-        if (authScheme == null) {
-            throw new IllegalArgumentException("Auth scheme may not be null");
-        }
-        if (context == null) {
-            throw new IllegalArgumentException("HTTP context may not be null");
-        }
+        Args.notNull(authhost, "Host");
+        Args.notNull(authScheme, "Auth scheme");
+        Args.notNull(context, "HTTP context");
 
         HttpClientContext clientContext = HttpClientContext.adapt(context);
 
@@ -247,12 +230,8 @@ abstract class AuthenticationStrategyImp
 
     public void authFailed(
             final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
-        if (authhost == null) {
-            throw new IllegalArgumentException("Host may not be null");
-        }
-        if (context == null) {
-            throw new IllegalArgumentException("HTTP context may not be null");
-        }
+        Args.notNull(authhost, "Host");
+        Args.notNull(context, "HTTP context");
 
         HttpClientContext clientContext = HttpClientContext.adapt(context);
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AutoRetryHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AutoRetryHttpClient.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AutoRetryHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/AutoRetryHttpClient.java Tue Dec 18 16:22:58 2012
@@ -44,6 +44,7 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 import org.apache.http.util.EntityUtils;
 
 /**
@@ -67,13 +68,8 @@ public class AutoRetryHttpClient impleme
     public AutoRetryHttpClient(
             final HttpClient client, final ServiceUnavailableRetryStrategy retryStrategy) {
         super();
-        if (client == null) {
-            throw new IllegalArgumentException("HttpClient may not be null");
-        }
-        if (retryStrategy == null) {
-            throw new IllegalArgumentException(
-                    "ServiceUnavailableRetryStrategy may not be null");
-        }
+        Args.notNull(client, "HttpClient");
+        Args.notNull(retryStrategy, "ServiceUnavailableRetryStrategy");
         this.backend = client;
         this.retryStrategy = retryStrategy;
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java Tue Dec 18 16:22:58 2012
@@ -34,6 +34,7 @@ import org.apache.http.auth.AuthScheme;
 import org.apache.http.client.AuthCache;
 import org.apache.http.conn.SchemePortResolver;
 import org.apache.http.impl.conn.DefaultSchemePortResolver;
+import org.apache.http.util.Args;
 
 /**
  * Default implementation of {@link AuthCache}.
@@ -74,23 +75,17 @@ public class BasicAuthCache implements A
     }
 
     public void put(final HttpHost host, final AuthScheme authScheme) {
-        if (host == null) {
-            throw new IllegalArgumentException("HTTP host may not be null");
-        }
+        Args.notNull(host, "HTTP host");
         this.map.put(getKey(host), authScheme);
     }
 
     public AuthScheme get(final HttpHost host) {
-        if (host == null) {
-            throw new IllegalArgumentException("HTTP host may not be null");
-        }
+        Args.notNull(host, "HTTP host");
         return this.map.get(getKey(host));
     }
 
     public void remove(final HttpHost host) {
-        if (host == null) {
-            throw new IllegalArgumentException("HTTP host may not be null");
-        }
+        Args.notNull(host, "HTTP host");
         this.map.remove(getKey(host));
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java Tue Dec 18 16:22:58 2012
@@ -30,10 +30,10 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.http.annotation.ThreadSafe;
-
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.Credentials;
 import org.apache.http.client.CredentialsProvider;
+import org.apache.http.util.Args;
 
 /**
  * Default implementation of {@link CredentialsProvider}.
@@ -56,9 +56,7 @@ public class BasicCredentialsProvider im
     public void setCredentials(
             final AuthScope authscope,
             final Credentials credentials) {
-        if (authscope == null) {
-            throw new IllegalArgumentException("Authentication scope may not be null");
-        }
+        Args.notNull(authscope, "Authentication scope");
         credMap.put(authscope, credentials);
     }
 
@@ -95,9 +93,7 @@ public class BasicCredentialsProvider im
     }
 
     public Credentials getCredentials(final AuthScope authscope) {
-        if (authscope == null) {
-            throw new IllegalArgumentException("Authentication scope may not be null");
-        }
+        Args.notNull(authscope, "Authentication scope");
         return matchCredentials(this.credMap, authscope);
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ClientParamsStack.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ClientParamsStack.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ClientParamsStack.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ClientParamsStack.java Tue Dec 18 16:22:58 2012
@@ -32,6 +32,7 @@ import org.apache.http.annotation.NotThr
 import org.apache.http.params.DefaultedHttpParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.AbstractHttpParams;
+import org.apache.http.util.Args;
 
 /**
  * Represents a stack of parameter collections.
@@ -190,10 +191,7 @@ public class ClientParamsStack extends A
      *          <code>null</code> if it is not set anywhere in this stack
      */
     public Object getParameter(String name) {
-        if (name == null) {
-            throw new IllegalArgumentException
-                ("Parameter name must not be null.");
-        }
+        Args.notNull(name, "Parameter name");
 
         Object result = null;
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java Tue Dec 18 16:22:58 2012
@@ -46,6 +46,7 @@ import org.apache.http.client.methods.Cl
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.client.utils.URIUtils;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 import org.apache.http.util.EntityUtils;
 
 /**
@@ -71,9 +72,7 @@ public abstract class CloseableHttpClien
     public CloseableHttpResponse execute(
             final HttpUriRequest request,
             final HttpContext context) throws IOException, ClientProtocolException {
-        if (request == null) {
-            throw new IllegalArgumentException("Request must not be null.");
-        }
+        Args.notNull(request, "HTTP request");
         return doExecute(determineTarget(request), request, context);
     }
 
@@ -126,9 +125,7 @@ public abstract class CloseableHttpClien
     public <T> T execute(final HttpHost target, final HttpRequest request,
             final ResponseHandler<? extends T> responseHandler, final HttpContext context)
             throws IOException, ClientProtocolException {
-        if (responseHandler == null) {
-            throw new IllegalArgumentException("Response handler must not be null.");
-        }
+        Args.notNull(responseHandler, "Response handler");
 
         HttpResponse response = execute(target, request, context);
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java Tue Dec 18 16:22:58 2012
@@ -26,15 +26,15 @@
  */
 package org.apache.http.impl.client;
 
-import org.apache.http.annotation.Immutable;
-
 import org.apache.http.HeaderElement;
 import org.apache.http.HeaderElementIterator;
 import org.apache.http.HttpResponse;
+import org.apache.http.annotation.Immutable;
 import org.apache.http.conn.ConnectionKeepAliveStrategy;
 import org.apache.http.message.BasicHeaderElementIterator;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 
 /**
  * Default implementation of a strategy deciding duration
@@ -51,9 +51,7 @@ public class DefaultConnectionKeepAliveS
     public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy();
 
     public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
+        Args.notNull(response, "HTTP response");
         HeaderElementIterator it = new BasicHeaderElementIterator(
                 response.headerIterator(HTTP.CONN_KEEP_ALIVE));
         while (it.hasNext()) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java Tue Dec 18 16:22:58 2012
@@ -34,14 +34,14 @@ import java.net.UnknownHostException;
 
 import javax.net.ssl.SSLException;
 
-import org.apache.http.annotation.Immutable;
-
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpRequest;
+import org.apache.http.annotation.Immutable;
 import org.apache.http.client.HttpRequestRetryHandler;
 import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.ExecutionContext;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 
 /**
  * The default {@link HttpRequestRetryHandler} used by request executors.
@@ -82,12 +82,8 @@ public class DefaultHttpRequestRetryHand
             final IOException exception,
             int executionCount,
             final HttpContext context) {
-        if (exception == null) {
-            throw new IllegalArgumentException("Exception parameter may not be null");
-        }
-        if (context == null) {
-            throw new IllegalArgumentException("HTTP context may not be null");
-        }
+        Args.notNull(exception, "Exception parameter");
+        Args.notNull(context, "HTTP context");
         if (executionCount > this.retryCount) {
             // Do not retry if over max retry count
             return false;

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java Tue Dec 18 16:22:58 2012
@@ -30,16 +30,16 @@ package org.apache.http.impl.client;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.http.annotation.Immutable;
-
 import org.apache.http.Header;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
+import org.apache.http.annotation.Immutable;
 import org.apache.http.auth.AUTH;
 import org.apache.http.auth.MalformedChallengeException;
 import org.apache.http.auth.params.AuthPNames;
 import org.apache.http.client.AuthenticationHandler;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 
 /**
  * Default {@link AuthenticationHandler} implementation for proxy host
@@ -60,9 +60,7 @@ public class DefaultProxyAuthenticationH
     public boolean isAuthenticationRequested(
             final HttpResponse response,
             final HttpContext context) {
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
+        Args.notNull(response, "HTTP response");
         int status = response.getStatusLine().getStatusCode();
         return status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED;
     }
@@ -70,9 +68,7 @@ public class DefaultProxyAuthenticationH
     public Map<String, Header> getChallenges(
             final HttpResponse response,
             final HttpContext context) throws MalformedChallengeException {
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
+        Args.notNull(response, "HTTP response");
         Header[] headers = response.getHeaders(AUTH.PROXY_AUTH);
         return parseChallenges(headers);
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java Tue Dec 18 16:22:58 2012
@@ -30,8 +30,6 @@ package org.apache.http.impl.client;
 import java.net.URI;
 import java.net.URISyntaxException;
 
-import org.apache.http.annotation.Immutable;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.Header;
@@ -40,6 +38,7 @@ import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.ProtocolException;
+import org.apache.http.annotation.Immutable;
 import org.apache.http.client.CircularRedirectException;
 import org.apache.http.client.RedirectHandler;
 import org.apache.http.client.methods.HttpGet;
@@ -47,8 +46,10 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.client.params.ClientPNames;
 import org.apache.http.client.utils.URIUtils;
 import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.ExecutionContext;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
+import org.apache.http.util.Asserts;
 
 /**
  * Default implementation of {@link RedirectHandler}.
@@ -72,9 +73,7 @@ public class DefaultRedirectHandler impl
     public boolean isRedirectRequested(
             final HttpResponse response,
             final HttpContext context) {
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
+        Args.notNull(response, "HTTP response");
 
         int statusCode = response.getStatusLine().getStatusCode();
         switch (statusCode) {
@@ -96,9 +95,7 @@ public class DefaultRedirectHandler impl
     public URI getLocationURI(
             final HttpResponse response,
             final HttpContext context) throws ProtocolException {
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
+        Args.notNull(response, "HTTP response");
         //get the location header to find out where to redirect to
         Header locationHeader = response.getFirstHeader("location");
         if (locationHeader == null) {
@@ -130,10 +127,7 @@ public class DefaultRedirectHandler impl
             // Adjust location URI
             HttpHost target = (HttpHost) context.getAttribute(
                     ExecutionContext.HTTP_TARGET_HOST);
-            if (target == null) {
-                throw new IllegalStateException("Target host not available " +
-                        "in the HTTP context");
-            }
+            Asserts.notNull(target, "Target host");
 
             HttpRequest request = (HttpRequest) context.getAttribute(
                     ExecutionContext.HTTP_REQUEST);

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java Tue Dec 18 16:22:58 2012
@@ -50,6 +50,8 @@ import org.apache.http.client.protocol.H
 import org.apache.http.client.utils.URIUtils;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
+import org.apache.http.util.Asserts;
 
 /**
  * Default implementation of {@link RedirectStrategy}. This strategy honors the restrictions
@@ -90,12 +92,8 @@ public class DefaultRedirectStrategy imp
             final HttpRequest request,
             final HttpResponse response,
             final HttpContext context) throws ProtocolException {
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
+        Args.notNull(request, "HTTP request");
+        Args.notNull(response, "HTTP response");
 
         int statusCode = response.getStatusLine().getStatusCode();
         String method = request.getRequestLine().getMethod();
@@ -117,15 +115,9 @@ public class DefaultRedirectStrategy imp
             final HttpRequest request,
             final HttpResponse response,
             final HttpContext context) throws ProtocolException {
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
-        if (context == null) {
-            throw new IllegalArgumentException("HTTP context may not be null");
-        }
+        Args.notNull(request, "HTTP request");
+        Args.notNull(response, "HTTP response");
+        Args.notNull(context, "HTTP context");
 
         HttpClientContext clientContext = HttpClientContext.adapt(context);
 
@@ -158,10 +150,7 @@ public class DefaultRedirectStrategy imp
                 }
                 // Adjust location URI
                 HttpHost target = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
-                if (target == null) {
-                    throw new IllegalStateException("Target host not available " +
-                            "in the HTTP context");
-                }
+                Asserts.notNull(target, "Target host");
                 URI requestURI = new URI(request.getRequestLine().getUri());
                 URI absoluteRequestURI = URIUtils.rewriteURI(requestURI, target, true);
                 uri = URIUtils.resolve(absoluteRequestURI, uri);

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java Tue Dec 18 16:22:58 2012
@@ -85,6 +85,8 @@ import org.apache.http.protocol.Executio
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpProcessor;
 import org.apache.http.protocol.HttpRequestExecutor;
+import org.apache.http.util.Args;
+import org.apache.http.util.Asserts;
 import org.apache.http.util.EntityUtils;
 
 /**
@@ -266,58 +268,19 @@ public class DefaultRequestDirector impl
             final UserTokenHandler userTokenHandler,
             final HttpParams params) {
 
-        if (log == null) {
-            throw new IllegalArgumentException
-                ("Log may not be null.");
-        }
-        if (requestExec == null) {
-            throw new IllegalArgumentException
-                ("Request executor may not be null.");
-        }
-        if (conman == null) {
-            throw new IllegalArgumentException
-                ("Client connection manager may not be null.");
-        }
-        if (reustrat == null) {
-            throw new IllegalArgumentException
-                ("Connection reuse strategy may not be null.");
-        }
-        if (kastrat == null) {
-            throw new IllegalArgumentException
-                ("Connection keep alive strategy may not be null.");
-        }
-        if (rouplan == null) {
-            throw new IllegalArgumentException
-                ("Route planner may not be null.");
-        }
-        if (httpProcessor == null) {
-            throw new IllegalArgumentException
-                ("HTTP protocol processor may not be null.");
-        }
-        if (retryHandler == null) {
-            throw new IllegalArgumentException
-                ("HTTP request retry handler may not be null.");
-        }
-        if (redirectStrategy == null) {
-            throw new IllegalArgumentException
-                ("Redirect strategy may not be null.");
-        }
-        if (targetAuthStrategy == null) {
-            throw new IllegalArgumentException
-                ("Target authentication strategy may not be null.");
-        }
-        if (proxyAuthStrategy == null) {
-            throw new IllegalArgumentException
-                ("Proxy authentication strategy may not be null.");
-        }
-        if (userTokenHandler == null) {
-            throw new IllegalArgumentException
-                ("User token handler may not be null.");
-        }
-        if (params == null) {
-            throw new IllegalArgumentException
-                ("HTTP parameters may not be null");
-        }
+        Args.notNull(log, "Log");
+        Args.notNull(requestExec, "Request executor");
+        Args.notNull(conman, "Client connection manager");
+        Args.notNull(reustrat, "Connection reuse strategy");
+        Args.notNull(kastrat, "Connection keep alive strategy");
+        Args.notNull(rouplan, "Route planner");
+        Args.notNull(httpProcessor, "HTTP protocol processor");
+        Args.notNull(retryHandler, "HTTP request retry handler");
+        Args.notNull(redirectStrategy, "Redirect strategy");
+        Args.notNull(targetAuthStrategy, "Target authentication strategy");
+        Args.notNull(proxyAuthStrategy, "Proxy authentication strategy");
+        Args.notNull(userTokenHandler, "User token handler");
+        Args.notNull(params, "HTTP parameters");
         this.log               = log;
         this.authenticator     = new HttpAuthenticator(log);
         this.requestExec        = requestExec;
@@ -780,11 +743,7 @@ public class DefaultRequestDirector impl
             target = (HttpHost) request.getParams().getParameter(
                 ClientPNames.DEFAULT_HOST);
         }
-        if (target == null) {
-            throw new IllegalStateException
-                ("Target host must not be null, or set in parameters.");
-        }
-
+        Asserts.notNull(target, "Target host");
         return this.routePlanner.determineRoute(target, request, context);
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java Tue Dec 18 16:22:58 2012
@@ -32,6 +32,7 @@ import org.apache.http.HttpStatus;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.client.ServiceUnavailableRetryStrategy;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 
 /**
  * Default implementation of the {@link ServiceUnavailableRetryStrategy} interface.
@@ -57,12 +58,8 @@ public class DefaultServiceUnavailableRe
 
     public DefaultServiceUnavailableRetryStrategy(int maxRetries, int retryInterval) {
         super();
-        if (maxRetries < 1) {
-            throw new IllegalArgumentException("MaxRetries must be greater than 1");
-        }
-        if (retryInterval < 1) {
-            throw new IllegalArgumentException("Retry interval must be greater than 1");
-        }
+        Args.positive(maxRetries, "Max retries");
+        Args.positive(retryInterval, "Retry interval");
         this.maxRetries = maxRetries;
         this.retryInterval = retryInterval;
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java?rev=1423516&r1=1423515&r2=1423516&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java Tue Dec 18 16:22:58 2012
@@ -30,16 +30,16 @@ package org.apache.http.impl.client;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.http.annotation.Immutable;
-
 import org.apache.http.Header;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
+import org.apache.http.annotation.Immutable;
 import org.apache.http.auth.AUTH;
 import org.apache.http.auth.MalformedChallengeException;
 import org.apache.http.auth.params.AuthPNames;
 import org.apache.http.client.AuthenticationHandler;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 
 /**
  * Default {@link AuthenticationHandler} implementation for target host
@@ -60,9 +60,7 @@ public class DefaultTargetAuthentication
     public boolean isAuthenticationRequested(
             final HttpResponse response,
             final HttpContext context) {
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
+        Args.notNull(response, "HTTP response");
         int status = response.getStatusLine().getStatusCode();
         return status == HttpStatus.SC_UNAUTHORIZED;
     }
@@ -70,9 +68,7 @@ public class DefaultTargetAuthentication
     public Map<String, Header> getChallenges(
             final HttpResponse response,
             final HttpContext context) throws MalformedChallengeException {
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
+        Args.notNull(response, "HTTP response");
         Header[] headers = response.getHeaders(AUTH.WWW_AUTH);
         return parseChallenges(headers);
     }



Mime
View raw message