hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1370923 [4/5] - in /httpcomponents/httpcore/trunk: httpcore-contrib/src/main/java/org/apache/http/contrib/compress/ httpcore-contrib/src/main/java/org/apache/http/contrib/logging/ httpcore-contrib/src/main/java/org/apache/http/contrib/sip/...
Date Wed, 08 Aug 2012 19:56:44 GMT
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderValueFormatter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderValueFormatter.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderValueFormatter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderValueFormatter.java Wed Aug  8 19:56:38 2012
@@ -30,6 +30,7 @@ package org.apache.http.message;
 import org.apache.http.HeaderElement;
 import org.apache.http.NameValuePair;
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -98,11 +99,7 @@ public class BasicHeaderValueFormatter i
     public CharArrayBuffer formatElements(CharArrayBuffer buffer,
                                           final HeaderElement[] elems,
                                           final boolean quote) {
-        if (elems == null) {
-            throw new IllegalArgumentException
-                ("Header element array must not be null.");
-        }
-
+        Args.notNull(elems, "Header element array");
         int len = estimateElementsLen(elems);
         if (buffer == null) {
             buffer = new CharArrayBuffer(len);
@@ -167,11 +164,7 @@ public class BasicHeaderValueFormatter i
     public CharArrayBuffer formatHeaderElement(CharArrayBuffer buffer,
                                                final HeaderElement elem,
                                                final boolean quote) {
-        if (elem == null) {
-            throw new IllegalArgumentException
-                ("Header element must not be null.");
-        }
-
+        Args.notNull(elem, "Header element");
         int len = estimateHeaderElementLen(elem);
         if (buffer == null) {
             buffer = new CharArrayBuffer(len);
@@ -255,11 +248,7 @@ public class BasicHeaderValueFormatter i
     public CharArrayBuffer formatParameters(CharArrayBuffer buffer,
                                             NameValuePair[] nvps,
                                             boolean quote) {
-        if (nvps == null) {
-            throw new IllegalArgumentException
-                ("Parameters must not be null.");
-        }
-
+        Args.notNull(nvps, "Header parameter array");
         int len = estimateParametersLen(nvps);
         if (buffer == null) {
             buffer = new CharArrayBuffer(len);
@@ -323,11 +312,7 @@ public class BasicHeaderValueFormatter i
     public CharArrayBuffer formatNameValuePair(CharArrayBuffer buffer,
                                                final NameValuePair nvp,
                                                final boolean quote) {
-        if (nvp == null) {
-            throw new IllegalArgumentException
-                ("NameValuePair must not be null.");
-        }
-
+        Args.notNull(nvp, "Name / value pair");
         int len = estimateNameValuePairLen(nvp);
         if (buffer == null) {
             buffer = new CharArrayBuffer(len);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderValueParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderValueParser.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderValueParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderValueParser.java Wed Aug  8 19:56:38 2012
@@ -27,14 +27,15 @@
 
 package org.apache.http.message;
 
-import java.util.List;
 import java.util.ArrayList;
+import java.util.List;
 
 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.protocol.HTTP;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -82,14 +83,8 @@ public class BasicHeaderValueParser impl
      */
     public final static
         HeaderElement[] parseElements(final String value,
-                                      HeaderValueParser parser)
-        throws ParseException {
-
-        if (value == null) {
-            throw new IllegalArgumentException
-                ("Value to parse may not be null");
-        }
-
+                                      HeaderValueParser parser) throws ParseException {
+        Args.notNull(value, "Value");
         if (parser == null)
             parser = BasicHeaderValueParser.INSTANCE;
 
@@ -103,14 +98,8 @@ public class BasicHeaderValueParser impl
     // non-javadoc, see interface HeaderValueParser
     public HeaderElement[] parseElements(final CharArrayBuffer buffer,
                                          final ParserCursor cursor) {
-
-        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");
         List<HeaderElement> elements = new ArrayList<HeaderElement>();
         while (!cursor.atEnd()) {
             HeaderElement element = parseHeaderElement(buffer, cursor);
@@ -132,14 +121,8 @@ public class BasicHeaderValueParser impl
      */
     public final static
         HeaderElement parseHeaderElement(final String value,
-                                         HeaderValueParser parser)
-        throws ParseException {
-
-        if (value == null) {
-            throw new IllegalArgumentException
-                ("Value to parse may not be null");
-        }
-
+                                         HeaderValueParser parser) throws ParseException {
+        Args.notNull(value, "Value");
         if (parser == null)
             parser = BasicHeaderValueParser.INSTANCE;
 
@@ -153,14 +136,8 @@ public class BasicHeaderValueParser impl
     // non-javadoc, see interface HeaderValueParser
     public HeaderElement parseHeaderElement(final CharArrayBuffer buffer,
                                             final ParserCursor cursor) {
-
-        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);
         NameValuePair[] params = null;
         if (!cursor.atEnd()) {
@@ -197,14 +174,8 @@ public class BasicHeaderValueParser impl
      */
     public final static
         NameValuePair[] parseParameters(final String value,
-                                        HeaderValueParser parser)
-        throws ParseException {
-
-        if (value == null) {
-            throw new IllegalArgumentException
-                ("Value to parse may not be null");
-        }
-
+                                        HeaderValueParser parser) throws ParseException {
+        Args.notNull(value, "Value");
         if (parser == null)
             parser = BasicHeaderValueParser.INSTANCE;
 
@@ -219,14 +190,8 @@ public class BasicHeaderValueParser impl
     // non-javadoc, see interface HeaderValueParser
     public NameValuePair[] parseParameters(final CharArrayBuffer buffer,
                                            final ParserCursor cursor) {
-
-        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");
         int pos = cursor.getPos();
         int indexTo = cursor.getUpperBound();
 
@@ -266,14 +231,8 @@ public class BasicHeaderValueParser impl
      */
     public final static
        NameValuePair parseNameValuePair(final String value,
-                                        HeaderValueParser parser)
-        throws ParseException {
-
-        if (value == null) {
-            throw new IllegalArgumentException
-                ("Value to parse may not be null");
-        }
-
+                                        HeaderValueParser parser) throws ParseException {
+        Args.notNull(value, "Value");
         if (parser == null)
             parser = BasicHeaderValueParser.INSTANCE;
 
@@ -304,13 +263,8 @@ public class BasicHeaderValueParser impl
     public NameValuePair parseNameValuePair(final CharArrayBuffer buffer,
                                             final ParserCursor cursor,
                                             final char[] delimiters) {
-
-        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");
 
         boolean terminated = false;
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHttpRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHttpRequest.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHttpRequest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHttpRequest.java Wed Aug  8 19:56:38 2012
@@ -33,6 +33,7 @@ import org.apache.http.RequestLine;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.util.Args;
 
 /**
  * Basic implementation of {@link HttpRequest}.
@@ -64,14 +65,8 @@ public class BasicHttpRequest extends Ab
      */
     public BasicHttpRequest(final String method, final String uri) {
         super();
-        if (method == null) {
-            throw new IllegalArgumentException("Method name may not be null");
-        }
-        if (uri == null) {
-            throw new IllegalArgumentException("Request URI may not be null");
-        }
-        this.method = method;
-        this.uri = uri;
+        this.method = Args.notNull(method, "Method name");
+        this.uri = Args.notNull(uri, "Request URI");
         this.requestline = null;
     }
 
@@ -94,10 +89,7 @@ public class BasicHttpRequest extends Ab
      */
     public BasicHttpRequest(final RequestLine requestline) {
         super();
-        if (requestline == null) {
-            throw new IllegalArgumentException("Request line may not be null");
-        }
-        this.requestline = requestline;
+        this.requestline = Args.notNull(requestline, "Request line");
         this.method = requestline.getMethod();
         this.uri = requestline.getUri();
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHttpResponse.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHttpResponse.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHttpResponse.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHttpResponse.java Wed Aug  8 19:56:38 2012
@@ -32,9 +32,10 @@ import java.util.Locale;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.ProtocolVersion;
-import org.apache.http.StatusLine;
 import org.apache.http.ReasonPhraseCatalog;
+import org.apache.http.StatusLine;
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * Basic implementation of {@link HttpResponse}.
@@ -66,12 +67,9 @@ public class BasicHttpResponse extends A
                              final ReasonPhraseCatalog catalog,
                              final Locale locale) {
         super();
-        if (statusline == null) {
-            throw new IllegalArgumentException("Status line may not be null.");
-        }
-        this.statusline    = statusline;
+        this.statusline = Args.notNull(statusline, "Status line");
         this.reasonCatalog = catalog;
-        this.locale        = (locale != null) ? locale : Locale.getDefault();
+        this.locale = (locale != null) ? locale : Locale.getDefault();
     }
 
     /**
@@ -124,10 +122,7 @@ public class BasicHttpResponse extends A
 
     // non-javadoc, see interface HttpResponse
     public void setStatusLine(final StatusLine statusline) {
-        if (statusline == null) {
-            throw new IllegalArgumentException("Status line may not be null");
-        }
-        this.statusline = statusline;
+        this.statusline = Args.notNull(statusline, "Status line");
     }
 
     // non-javadoc, see interface HttpResponse
@@ -152,12 +147,8 @@ public class BasicHttpResponse extends A
 
     // non-javadoc, see interface HttpResponse
     public void setReasonPhrase(String reason) {
-
-        if ((reason != null) && ((reason.indexOf('\n') >= 0) ||
-                                 (reason.indexOf('\r') >= 0))
-            ) {
-            throw new IllegalArgumentException("Line break in reason phrase.");
-        }
+        Args.check(reason == null || (reason.indexOf('\n') == 0 && reason.indexOf('\r') == 0), 
+                "Line break in reason phrase.");
         this.statusline = new BasicStatusLine(this.statusline.getProtocolVersion(),
                                               this.statusline.getStatusCode(),
                                               reason);
@@ -169,11 +160,8 @@ public class BasicHttpResponse extends A
     }
 
     // non-javadoc, see interface HttpResponse
-    public void setLocale(Locale loc) {
-        if (loc == null) {
-            throw new IllegalArgumentException("Locale may not be null.");
-        }
-        this.locale = loc;
+    public void setLocale(Locale locale) {
+        this.locale =  Args.notNull(locale, "Locale");
         final int code = this.statusline.getStatusCode();
         this.statusline = new BasicStatusLine
             (this.statusline.getProtocolVersion(), code, getReason(code));

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicLineFormatter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicLineFormatter.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicLineFormatter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicLineFormatter.java Wed Aug  8 19:56:38 2012
@@ -27,12 +27,13 @@
 
 package org.apache.http.message;
 
+import org.apache.http.FormattedHeader;
+import org.apache.http.Header;
 import org.apache.http.ProtocolVersion;
 import org.apache.http.RequestLine;
 import org.apache.http.StatusLine;
-import org.apache.http.Header;
-import org.apache.http.FormattedHeader;
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -107,11 +108,7 @@ public class BasicLineFormatter implemen
     // non-javadoc, see interface LineFormatter
     public CharArrayBuffer appendProtocolVersion(final CharArrayBuffer buffer,
                                                  final ProtocolVersion version) {
-        if (version == null) {
-            throw new IllegalArgumentException
-                ("Protocol version may not be null");
-        }
-
+        Args.notNull(version, "Protocol version");
         // can't use initBuffer, that would clear the argument!
         CharArrayBuffer result = buffer;
         final int len = estimateProtocolVersionLen(version);
@@ -166,11 +163,7 @@ public class BasicLineFormatter implemen
     // non-javadoc, see interface LineFormatter
     public CharArrayBuffer formatRequestLine(CharArrayBuffer buffer,
                                              RequestLine reqline) {
-        if (reqline == null) {
-            throw new IllegalArgumentException
-                ("Request line may not be null");
-        }
-
+        Args.notNull(reqline, "Request line");
         CharArrayBuffer result = initBuffer(buffer);
         doFormatRequestLine(result, reqline);
 
@@ -226,11 +219,7 @@ public class BasicLineFormatter implemen
     // non-javadoc, see interface LineFormatter
     public CharArrayBuffer formatStatusLine(final CharArrayBuffer buffer,
                                             final StatusLine statline) {
-        if (statline == null) {
-            throw new IllegalArgumentException
-                ("Status line may not be null");
-        }
-
+        Args.notNull(statline, "Status line");
         CharArrayBuffer result = initBuffer(buffer);
         doFormatStatusLine(result, statline);
 
@@ -288,10 +277,7 @@ public class BasicLineFormatter implemen
     // non-javadoc, see interface LineFormatter
     public CharArrayBuffer formatHeader(CharArrayBuffer buffer,
                                         Header header) {
-        if (header == null) {
-            throw new IllegalArgumentException
-                ("Header may not be null");
-        }
+        Args.notNull(header, "Header");
         CharArrayBuffer result = null;
 
         if (header instanceof FormattedHeader) {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicLineParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicLineParser.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicLineParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicLineParser.java Wed Aug  8 19:56:38 2012
@@ -27,14 +27,15 @@
 
 package org.apache.http.message;
 
+import org.apache.http.Header;
 import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolVersion;
 import org.apache.http.ParseException;
+import org.apache.http.ProtocolVersion;
 import org.apache.http.RequestLine;
 import org.apache.http.StatusLine;
-import org.apache.http.Header;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.protocol.HTTP;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -103,14 +104,8 @@ public class BasicLineParser implements 
 
     public final static
         ProtocolVersion parseProtocolVersion(String value,
-                                             LineParser parser)
-        throws ParseException {
-
-        if (value == null) {
-            throw new IllegalArgumentException
-                ("Value to parse may not be null.");
-        }
-
+                                             LineParser parser) throws ParseException {
+        Args.notNull(value, "Value");
         if (parser == null)
             parser = BasicLineParser.INSTANCE;
 
@@ -123,16 +118,9 @@ public class BasicLineParser implements 
 
     // non-javadoc, see interface LineParser
     public ProtocolVersion parseProtocolVersion(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");
-        }
-
+                                                final ParserCursor cursor) throws ParseException {
+        Args.notNull(buffer, "Char array buffer");
+        Args.notNull(cursor, "Parser cursor");
         final String protoname = this.protocol.getProtocol();
         final int protolength  = protoname.length();
 
@@ -220,13 +208,8 @@ public class BasicLineParser implements 
     // non-javadoc, see interface LineParser
     public boolean hasProtocolVersion(final CharArrayBuffer buffer,
                                       final ParserCursor cursor) {
-
-        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");
         int index = cursor.getPos();
 
         final String protoname = this.protocol.getProtocol();
@@ -268,14 +251,8 @@ public class BasicLineParser implements 
 
     public final static
         RequestLine parseRequestLine(final String value,
-                                     LineParser parser)
-        throws ParseException {
-
-        if (value == null) {
-            throw new IllegalArgumentException
-                ("Value to parse may not be null.");
-        }
-
+                                     LineParser parser) throws ParseException {
+        Args.notNull(value, "Value");
         if (parser == null)
             parser = BasicLineParser.INSTANCE;
 
@@ -296,16 +273,10 @@ public class BasicLineParser implements 
      * @throws ParseException        in case of a parse error
      */
     public RequestLine parseRequestLine(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");
-        }
+                                        final ParserCursor cursor) throws ParseException {
 
+        Args.notNull(buffer, "Char array buffer");
+        Args.notNull(cursor, "Parser cursor");
         int indexFrom = cursor.getPos();
         int indexTo = cursor.getUpperBound();
 
@@ -368,14 +339,8 @@ public class BasicLineParser implements 
 
     public final static
         StatusLine parseStatusLine(final String value,
-                                   LineParser parser)
-        throws ParseException {
-
-        if (value == null) {
-            throw new IllegalArgumentException
-                ("Value to parse may not be null.");
-        }
-
+                                   LineParser parser) throws ParseException {
+        Args.notNull(value, "Value");
         if (parser == null)
             parser = BasicLineParser.INSTANCE;
 
@@ -388,16 +353,9 @@ public class BasicLineParser implements 
 
     // non-javadoc, see interface LineParser
     public StatusLine parseStatusLine(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");
-        }
-
+                                      final ParserCursor cursor) throws ParseException {
+        Args.notNull(buffer, "Char array buffer");
+        Args.notNull(cursor, "Parser cursor");
         int indexFrom = cursor.getPos();
         int indexTo = cursor.getUpperBound();
 
@@ -466,14 +424,8 @@ public class BasicLineParser implements 
 
     public final static
         Header parseHeader(final String value,
-                           LineParser parser)
-        throws ParseException {
-
-        if (value == null) {
-            throw new IllegalArgumentException
-                ("Value to parse may not be null");
-        }
-
+                           LineParser parser) throws ParseException {
+        Args.notNull(value, "Value");
         if (parser == null)
             parser = BasicLineParser.INSTANCE;
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicListHeaderIterator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicListHeaderIterator.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicListHeaderIterator.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicListHeaderIterator.java Wed Aug  8 19:56:38 2012
@@ -33,6 +33,7 @@ import java.util.NoSuchElementException;
 import org.apache.http.Header;
 import org.apache.http.HeaderIterator;
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * Implementation of a {@link HeaderIterator} based on a {@link List}.
@@ -80,12 +81,8 @@ public class BasicListHeaderIterator imp
      *                  <code>null</code> for any
      */
     public BasicListHeaderIterator(List<Header> headers, String name) {
-        if (headers == null) {
-            throw new IllegalArgumentException
-                ("Header list must not be null.");
-        }
-
-        this.allHeaders = headers;
+        super();
+        this.allHeaders = Args.notNull(headers, "Header list");
         this.headerName = name;
         this.currentIndex = findNext(-1);
         this.lastIndex = -1;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicNameValuePair.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicNameValuePair.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicNameValuePair.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicNameValuePair.java Wed Aug  8 19:56:38 2012
@@ -31,6 +31,7 @@ import java.io.Serializable;
 
 import org.apache.http.NameValuePair;
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 import org.apache.http.util.LangUtils;
 
 /**
@@ -54,10 +55,7 @@ public class BasicNameValuePair implemen
      */
     public BasicNameValuePair(final String name, final String value) {
         super();
-        if (name == null) {
-            throw new IllegalArgumentException("Name may not be null");
-        }
-        this.name = name;
+        this.name = Args.notNull(name, "Name");
         this.value = value;
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicRequestLine.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicRequestLine.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicRequestLine.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicRequestLine.java Wed Aug  8 19:56:38 2012
@@ -32,6 +32,7 @@ import java.io.Serializable;
 import org.apache.http.ProtocolVersion;
 import org.apache.http.RequestLine;
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 
 /**
  * Basic implementation of {@link RequestLine}.
@@ -51,21 +52,9 @@ public class BasicRequestLine implements
                             final String uri,
                             final ProtocolVersion version) {
         super();
-        if (method == null) {
-            throw new IllegalArgumentException
-                ("Method must not be null.");
-        }
-        if (uri == null) {
-            throw new IllegalArgumentException
-                ("URI must not be null.");
-        }
-        if (version == null) {
-            throw new IllegalArgumentException
-                ("Protocol version must not be null.");
-        }
-        this.method = method;
-        this.uri = uri;
-        this.protoversion = version;
+        this.method = Args.notNull(method, "Method");
+        this.uri = Args.notNull(uri, "URI");
+        this.protoversion = Args.notNull(version, "Version");
     }
 
     public String getMethod() {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicStatusLine.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicStatusLine.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicStatusLine.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicStatusLine.java Wed Aug  8 19:56:38 2012
@@ -32,6 +32,7 @@ import java.io.Serializable;
 import org.apache.http.ProtocolVersion;
 import org.apache.http.StatusLine;
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 
 /**
  * Basic implementation of {@link StatusLine}
@@ -66,16 +67,8 @@ public class BasicStatusLine implements 
     public BasicStatusLine(final ProtocolVersion version, int statusCode,
                            final String reasonPhrase) {
         super();
-        if (version == null) {
-            throw new IllegalArgumentException
-                ("Protocol version may not be null.");
-        }
-        if (statusCode < 0) {
-            throw new IllegalArgumentException
-                ("Status code may not be negative.");
-        }
-        this.protoVersion = version;
-        this.statusCode   = statusCode;
+        this.protoVersion = Args.notNull(version, "Version");
+        this.statusCode = Args.notNegative(statusCode, "Status code");
         this.reasonPhrase = reasonPhrase;
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicTokenIterator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicTokenIterator.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicTokenIterator.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicTokenIterator.java Wed Aug  8 19:56:38 2012
@@ -33,6 +33,7 @@ import org.apache.http.HeaderIterator;
 import org.apache.http.ParseException;
 import org.apache.http.TokenIterator;
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * Basic implementation of a {@link TokenIterator}.
@@ -80,12 +81,8 @@ public class BasicTokenIterator implemen
      * @param headerIterator    the iterator for the headers to tokenize
      */
     public BasicTokenIterator(final HeaderIterator headerIterator) {
-        if (headerIterator == null) {
-            throw new IllegalArgumentException
-                ("Header iterator must not be null.");
-        }
-
-        this.headerIt = headerIterator;
+        super();
+        this.headerIt = Args.notNull(headerIterator, "Header iterator");
         this.searchPos = findNext(-1);
     }
 
@@ -226,11 +223,7 @@ public class BasicTokenIterator implemen
      *          negative if no token start could be found
      */
     protected int findTokenStart(int from) {
-        if (from < 0) {
-            throw new IllegalArgumentException
-                ("Search position must not be negative: " + from);
-        }
-
+        Args.notNegative(from, "Search position");
         boolean found = false;
         while (!found && (this.currentHeader != null)) {
 
@@ -282,11 +275,7 @@ public class BasicTokenIterator implemen
      *         tokens for <tt>#</tt>.
      */
     protected int findTokenSeparator(int from) {
-        if (from < 0) {
-            throw new IllegalArgumentException
-                ("Search position must not be negative: " + from);
-        }
-
+        Args.notNegative(from, "Search position");
         boolean found = false;
         final int to = this.currentHeader.length();
         while (!found && (from < to)) {
@@ -322,11 +311,7 @@ public class BasicTokenIterator implemen
      *          point to a token character in the current header value.
      */
     protected int findTokenEnd(int from) {
-        if (from < 0) {
-            throw new IllegalArgumentException
-                ("Token start position must not be negative: " + from);
-        }
-
+        Args.notNegative(from, "Search position");
         final int to = this.currentHeader.length();
         int end = from+1;
         while ((end < to) && isTokenChar(this.currentHeader.charAt(end))) {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BufferedHeader.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BufferedHeader.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BufferedHeader.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BufferedHeader.java Wed Aug  8 19:56:38 2012
@@ -33,6 +33,7 @@ import org.apache.http.FormattedHeader;
 import org.apache.http.HeaderElement;
 import org.apache.http.ParseException;
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -75,10 +76,7 @@ public class BufferedHeader implements F
         throws ParseException {
 
         super();
-        if (buffer == null) {
-            throw new IllegalArgumentException
-                ("Char array buffer may not be null");
-        }
+        Args.notNull(buffer, "Char array buffer");
         int colon = buffer.indexOf(':');
         if (colon == -1) {
             throw new ParseException

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/LineFormatter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/LineFormatter.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/LineFormatter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/LineFormatter.java Wed Aug  8 19:56:38 2012
@@ -27,10 +27,10 @@
 
 package org.apache.http.message;
 
+import org.apache.http.Header;
 import org.apache.http.ProtocolVersion;
 import org.apache.http.RequestLine;
 import org.apache.http.StatusLine;
-import org.apache.http.Header;
 import org.apache.http.util.CharArrayBuffer;
 
 /**

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/LineParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/LineParser.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/LineParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/LineParser.java Wed Aug  8 19:56:38 2012
@@ -27,11 +27,11 @@
 
 package org.apache.http.message;
 
-import org.apache.http.ProtocolVersion;
+import org.apache.http.Header;
 import org.apache.http.ParseException;
+import org.apache.http.ProtocolVersion;
 import org.apache.http.RequestLine;
 import org.apache.http.StatusLine;
-import org.apache.http.Header;
 import org.apache.http.util.CharArrayBuffer;
 
 /**

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java Wed Aug  8 19:56:38 2012
@@ -29,8 +29,6 @@ package org.apache.http.params;
 
 import java.util.Set;
 
-import org.apache.http.params.HttpParams;
-
 
 /**
  * Abstract base class for parameter collections.

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java Wed Aug  8 19:56:38 2012
@@ -29,13 +29,12 @@ package org.apache.http.params;
 
 import java.io.Serializable;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Iterator;
+import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.params.HttpParams;
 
 /**
  * Default implementation of {@link HttpParams} interface.

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java Wed Aug  8 19:56:38 2012
@@ -30,7 +30,7 @@ package org.apache.http.params;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 
 /**
  * {@link HttpParams} implementation that delegates resolution of a parameter
@@ -53,10 +53,7 @@ public final class DefaultedHttpParams e
      */
     public DefaultedHttpParams(final HttpParams local, final HttpParams defaults) {
         super();
-        if (local == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
-        this.local = local;
+        this.local = Args.notNull(local, "Local HTTP parameters");
         this.defaults = defaults;
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpAbstractParamBean.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpAbstractParamBean.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpAbstractParamBean.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpAbstractParamBean.java Wed Aug  8 19:56:38 2012
@@ -27,6 +27,8 @@
 
 package org.apache.http.params;
 
+import org.apache.http.util.Args;
+
 /**
  * @since 4.0
  */
@@ -35,9 +37,8 @@ public abstract class HttpAbstractParamB
     protected final HttpParams params;
 
     public HttpAbstractParamBean (final HttpParams params) {
-        if (params == null)
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        this.params = params;
+        super();
+        this.params = Args.notNull(params, "HTTP parameters");
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpConnectionParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpConnectionParams.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpConnectionParams.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpConnectionParams.java Wed Aug  8 19:56:38 2012
@@ -27,6 +27,8 @@
 
 package org.apache.http.params;
 
+import org.apache.http.util.Args;
+
 /**
  * Utility class for accessing connection parameters in {@link HttpParams}.
  *
@@ -46,9 +48,7 @@ public final class HttpConnectionParams 
      * @return SO_TIMEOUT.
      */
     public static int getSoTimeout(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         return params.getIntParameter(CoreConnectionPNames.SO_TIMEOUT, 0);
     }
 
@@ -59,9 +59,7 @@ public final class HttpConnectionParams 
      * @param timeout SO_TIMEOUT.
      */
     public static void setSoTimeout(final HttpParams params, int timeout) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, timeout);
 
     }
@@ -76,9 +74,7 @@ public final class HttpConnectionParams 
      * @since 4.1
      */
     public static boolean getSoReuseaddr(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         return params.getBooleanParameter(CoreConnectionPNames.SO_REUSEADDR, false);
     }
 
@@ -91,9 +87,7 @@ public final class HttpConnectionParams 
      * @since 4.1
      */
     public static void setSoReuseaddr(final HttpParams params, boolean reuseaddr) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         params.setBooleanParameter(CoreConnectionPNames.SO_REUSEADDR, reuseaddr);
     }
 
@@ -105,11 +99,8 @@ public final class HttpConnectionParams 
      * @return Nagle's algorithm flag
      */
     public static boolean getTcpNoDelay(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
-        return params.getBooleanParameter
-            (CoreConnectionPNames.TCP_NODELAY, true);
+        Args.notNull(params, "HTTP parameters");
+        return params.getBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true);
     }
 
     /**
@@ -119,9 +110,7 @@ public final class HttpConnectionParams 
      * @param value Nagle's algorithm flag
      */
     public static void setTcpNoDelay(final HttpParams params, boolean value) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, value);
     }
 
@@ -133,11 +122,8 @@ public final class HttpConnectionParams 
      * @return socket buffer size
      */
     public static int getSocketBufferSize(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
-        return params.getIntParameter
-            (CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
+        Args.notNull(params, "HTTP parameters");
+        return params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
     }
 
     /**
@@ -148,9 +134,7 @@ public final class HttpConnectionParams 
      * @param size socket buffer size
      */
     public static void setSocketBufferSize(final HttpParams params, int size) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         params.setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, size);
     }
 
@@ -162,9 +146,7 @@ public final class HttpConnectionParams 
      * @return SO_LINGER.
      */
     public static int getLinger(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         return params.getIntParameter(CoreConnectionPNames.SO_LINGER, -1);
     }
 
@@ -175,9 +157,7 @@ public final class HttpConnectionParams 
      * @param value SO_LINGER.
      */
     public static void setLinger(final HttpParams params, int value) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         params.setIntParameter(CoreConnectionPNames.SO_LINGER, value);
     }
 
@@ -189,11 +169,8 @@ public final class HttpConnectionParams 
      * @return connect timeout.
      */
     public static int getConnectionTimeout(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
-        return params.getIntParameter
-            (CoreConnectionPNames.CONNECTION_TIMEOUT, 0);
+        Args.notNull(params, "HTTP parameters");
+        return params.getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 0);
     }
 
     /**
@@ -204,11 +181,8 @@ public final class HttpConnectionParams 
      * @param timeout connect timeout.
      */
     public static void setConnectionTimeout(final HttpParams params, int timeout) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
-        params.setIntParameter
-            (CoreConnectionPNames.CONNECTION_TIMEOUT, timeout);
+        Args.notNull(params, "HTTP parameters");
+        params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout);
     }
 
     /**
@@ -219,11 +193,8 @@ public final class HttpConnectionParams 
      * @return stale connection check flag.
      */
     public static boolean isStaleCheckingEnabled(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
-        return params.getBooleanParameter
-            (CoreConnectionPNames.STALE_CONNECTION_CHECK, true);
+        Args.notNull(params, "HTTP parameters");
+        return params.getBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, true);
     }
 
     /**
@@ -234,11 +205,8 @@ public final class HttpConnectionParams 
      * @param value stale connection check flag.
      */
     public static void setStaleCheckingEnabled(final HttpParams params, boolean value) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
-        params.setBooleanParameter
-            (CoreConnectionPNames.STALE_CONNECTION_CHECK, value);
+        Args.notNull(params, "HTTP parameters");
+        params.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, value);
     }
 
     /**
@@ -251,9 +219,7 @@ public final class HttpConnectionParams 
      * @since 4.2
      */
     public static boolean getSoKeepalive(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         return params.getBooleanParameter(CoreConnectionPNames.SO_KEEPALIVE, false);
     }
 
@@ -266,13 +232,8 @@ public final class HttpConnectionParams 
      * @since 4.2
      */
     public static void setSoKeepalive(final HttpParams params, boolean enableKeepalive) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         params.setBooleanParameter(CoreConnectionPNames.SO_KEEPALIVE, enableKeepalive);
     }
 
-
-
-
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpProtocolParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpProtocolParams.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpProtocolParams.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpProtocolParams.java Wed Aug  8 19:56:38 2012
@@ -27,11 +27,12 @@
 
 package org.apache.http.params;
 
+import java.nio.charset.CodingErrorAction;
+
 import org.apache.http.HttpVersion;
 import org.apache.http.ProtocolVersion;
 import org.apache.http.protocol.HTTP;
-
-import java.nio.charset.CodingErrorAction;
+import org.apache.http.util.Args;
 
 /**
  * Utility class for accessing protocol parameters in {@link HttpParams}.
@@ -54,9 +55,7 @@ public final class HttpProtocolParams im
      * @return HTTP element charset.
      */
     public static String getHttpElementCharset(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         String charset = (String) params.getParameter
             (CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
         if (charset == null) {
@@ -72,9 +71,7 @@ public final class HttpProtocolParams im
      * @param charset HTTP element charset.
      */
     public static void setHttpElementCharset(final HttpParams params, final String charset) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         params.setParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET, charset);
     }
 
@@ -86,9 +83,7 @@ public final class HttpProtocolParams im
      * @return HTTP content charset.
      */
     public static String getContentCharset(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         String charset = (String) params.getParameter
             (CoreProtocolPNames.HTTP_CONTENT_CHARSET);
         if (charset == null) {
@@ -104,9 +99,7 @@ public final class HttpProtocolParams im
      * @param charset HTTP content charset.
      */
     public static void setContentCharset(final HttpParams params, final String charset) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         params.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, charset);
     }
 
@@ -118,9 +111,7 @@ public final class HttpProtocolParams im
      * @return HTTP protocol version.
      */
     public static ProtocolVersion getVersion(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         Object param = params.getParameter
             (CoreProtocolPNames.PROTOCOL_VERSION);
         if (param == null) {
@@ -136,9 +127,7 @@ public final class HttpProtocolParams im
      * @param version HTTP protocol version.
      */
     public static void setVersion(final HttpParams params, final ProtocolVersion version) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, version);
     }
 
@@ -150,9 +139,7 @@ public final class HttpProtocolParams im
      * @return User agent string.
      */
     public static String getUserAgent(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         return (String) params.getParameter(CoreProtocolPNames.USER_AGENT);
     }
 
@@ -163,9 +150,7 @@ public final class HttpProtocolParams im
      * @param useragent User agent string.
      */
     public static void setUserAgent(final HttpParams params, final String useragent) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         params.setParameter(CoreProtocolPNames.USER_AGENT, useragent);
     }
 
@@ -177,11 +162,8 @@ public final class HttpProtocolParams im
      * @return User agent string.
      */
     public static boolean useExpectContinue(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
-        return params.getBooleanParameter
-            (CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
+        Args.notNull(params, "HTTP parameters");
+        return params.getBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
     }
 
     /**
@@ -191,9 +173,7 @@ public final class HttpProtocolParams im
      * @param b expect-continue flag.
      */
     public static void setUseExpectContinue(final HttpParams params, boolean b) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         params.setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, b);
     }
 
@@ -205,9 +185,7 @@ public final class HttpProtocolParams im
      * @since 4.2
      */
     public static CodingErrorAction getMalformedInputAction(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         Object param = params.getParameter(CoreProtocolPNames.HTTP_MALFORMED_INPUT_ACTION);
         if (param == null) {
             // the default CodingErrorAction
@@ -224,9 +202,7 @@ public final class HttpProtocolParams im
      * @since 4.2
      */
     public static void setMalformedInputAction(final HttpParams params, CodingErrorAction action) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         params.setParameter(CoreProtocolPNames.HTTP_MALFORMED_INPUT_ACTION, action);
     }
 
@@ -238,9 +214,7 @@ public final class HttpProtocolParams im
      * @since 4.2
      */
     public static CodingErrorAction getUnmappableInputAction(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         Object param = params.getParameter(CoreProtocolPNames.HTTP_UNMAPPABLE_INPUT_ACTION);
         if (param == null) {
             // the default CodingErrorAction
@@ -257,9 +231,8 @@ public final class HttpProtocolParams im
      * @since 4.2
      */
     public static void setUnmappableInputAction(final HttpParams params, CodingErrorAction action) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may no be null");
-        }
+        Args.notNull(params, "HTTP parameters");
         params.setParameter(CoreProtocolPNames.HTTP_UNMAPPABLE_INPUT_ACTION, action);
     }
+
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java Wed Aug  8 19:56:38 2012
@@ -42,6 +42,7 @@ import java.util.concurrent.locks.Reentr
 
 import org.apache.http.annotation.ThreadSafe;
 import org.apache.http.concurrent.FutureCallback;
+import org.apache.http.util.Args;
 
 /**
  * Abstract synchronous (blocking) pool of connections.
@@ -79,24 +80,15 @@ public abstract class AbstractConnPool<T
             int defaultMaxPerRoute,
             int maxTotal) {
         super();
-        if (connFactory == null) {
-            throw new IllegalArgumentException("Connection factory may not null");
-        }
-        if (defaultMaxPerRoute <= 0) {
-            throw new IllegalArgumentException("Max per route value may not be negative or zero");
-        }
-        if (maxTotal <= 0) {
-            throw new IllegalArgumentException("Max total value may not be negative or zero");
-        }
+        this.connFactory = Args.notNull(connFactory, "Connection factory");
+        this.defaultMaxPerRoute = Args.notNegative(defaultMaxPerRoute, "Max per route value");
+        this.maxTotal = Args.notNegative(maxTotal, "Max total value");
         this.lock = new ReentrantLock();
-        this.connFactory = connFactory;
         this.routeToPool = new HashMap<T, RouteSpecificPool<T, C, E>>();
         this.leased = new HashSet<E>();
         this.available = new LinkedList<E>();
         this.pending = new LinkedList<PoolEntryFuture<E>>();
         this.maxPerRoute = new HashMap<T, Integer>();
-        this.defaultMaxPerRoute = defaultMaxPerRoute;
-        this.maxTotal = maxTotal;
     }
 
     /**
@@ -160,9 +152,7 @@ public abstract class AbstractConnPool<T
      * returned by this method in order for the lease operation to complete.
      */
     public Future<E> lease(final T route, final Object state, final FutureCallback<E> callback) {
-        if (route == null) {
-            throw new IllegalArgumentException("Route may not be null");
-        }
+        Args.notNull(route, "Route");
         if (this.isShutDown) {
             throw new IllegalStateException("Connection pool shut down");
         }
@@ -339,9 +329,7 @@ public abstract class AbstractConnPool<T
     }
 
     public void setMaxTotal(int max) {
-        if (max <= 0) {
-            throw new IllegalArgumentException("Max value may not be negative or zero");
-        }
+        Args.notNegative(max, "Max value");        
         this.lock.lock();
         try {
             this.maxTotal = max;
@@ -360,9 +348,7 @@ public abstract class AbstractConnPool<T
     }
 
     public void setDefaultMaxPerRoute(int max) {
-        if (max <= 0) {
-            throw new IllegalArgumentException("Max value may not be negative or zero");
-        }
+        Args.notNegative(max, "Max per route value");        
         this.lock.lock();
         try {
             this.defaultMaxPerRoute = max;
@@ -381,12 +367,8 @@ public abstract class AbstractConnPool<T
     }
 
     public void setMaxPerRoute(final T route, int max) {
-        if (route == null) {
-            throw new IllegalArgumentException("Route may not be null");
-        }
-        if (max <= 0) {
-            throw new IllegalArgumentException("Max value may not be negative or zero");
-        }
+        Args.notNull(route, "Route");
+        Args.notNegative(max, "Max per route value");        
         this.lock.lock();
         try {
             this.maxPerRoute.put(route, max);
@@ -396,9 +378,7 @@ public abstract class AbstractConnPool<T
     }
 
     public int getMaxPerRoute(T route) {
-        if (route == null) {
-            throw new IllegalArgumentException("Route may not be null");
-        }
+        Args.notNull(route, "Route");
         this.lock.lock();
         try {
             return getMax(route);
@@ -421,9 +401,7 @@ public abstract class AbstractConnPool<T
     }
 
     public PoolStats getStats(final T route) {
-        if (route == null) {
-            throw new IllegalArgumentException("Route may not be null");
-        }
+        Args.notNull(route, "Route");
         this.lock.lock();
         try {
             RouteSpecificPool<T, C, E> pool = getPool(route);
@@ -445,9 +423,7 @@ public abstract class AbstractConnPool<T
      * @param tunit time unit.
      */
     public void closeIdle(long idletime, final TimeUnit tunit) {
-        if (tunit == null) {
-            throw new IllegalArgumentException("Time unit must not be null.");
-        }
+        Args.notNull(tunit, "Time unit");
         long time = tunit.toMillis(idletime);
         if (time < 0) {
             time = 0;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/PoolEntry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/PoolEntry.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/PoolEntry.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/PoolEntry.java Wed Aug  8 19:56:38 2012
@@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.http.annotation.GuardedBy;
 import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * Pool entry containing a pool connection object along with its route.
@@ -77,15 +78,9 @@ public abstract class PoolEntry<T, C> {
     public PoolEntry(final String id, final T route, final C conn,
             final long timeToLive, final TimeUnit tunit) {
         super();
-        if (route == null) {
-            throw new IllegalArgumentException("Route may not be null");
-        }
-        if (conn == null) {
-            throw new IllegalArgumentException("Connection may not be null");
-        }
-        if (tunit == null) {
-            throw new IllegalArgumentException("Time unit may not be null");
-        }
+        Args.notNull(route, "Route");
+        Args.notNull(conn, "Connection");
+        Args.notNull(tunit, "Time unit");
         this.id = id;
         this.route = route;
         this.conn = conn;
@@ -146,9 +141,7 @@ public abstract class PoolEntry<T, C> {
     }
 
     public synchronized void updateExpiry(final long time, final TimeUnit tunit) {
-        if (tunit == null) {
-            throw new IllegalArgumentException("Time unit may not be null");
-        }
+        Args.notNull(tunit, "Time unit");
         this.updated = System.currentTimeMillis();
         long newExpiry;
         if (time > 0) {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/RouteSpecificPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/RouteSpecificPool.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/RouteSpecificPool.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/RouteSpecificPool.java Wed Aug  8 19:56:38 2012
@@ -32,6 +32,7 @@ import java.util.LinkedList;
 import java.util.Set;
 
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 
 @NotThreadSafe
 abstract class RouteSpecificPool<T, C, E extends PoolEntry<T, C>> {
@@ -106,9 +107,7 @@ abstract class RouteSpecificPool<T, C, E
     }
 
     public boolean remove(final E entry) {
-        if (entry == null) {
-            throw new IllegalArgumentException("Pool entry may not be null");
-        }
+        Args.notNull(entry, "Pool entry");
         if (!this.available.remove(entry)) {
             if (!this.leased.remove(entry)) {
                 return false;
@@ -118,9 +117,7 @@ abstract class RouteSpecificPool<T, C, E
     }
 
     public void free(final E entry, boolean reusable) {
-        if (entry == null) {
-            throw new IllegalArgumentException("Pool entry may not be null");
-        }
+        Args.notNull(entry, "Pool entry");
         boolean found = this.leased.remove(entry);
         if (!found) {
             throw new IllegalStateException("Entry " + entry +

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/BasicHttpContext.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/BasicHttpContext.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/BasicHttpContext.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/BasicHttpContext.java Wed Aug  8 19:56:38 2012
@@ -31,6 +31,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * Default implementation of {@link HttpContext}.
@@ -56,9 +57,7 @@ public class BasicHttpContext implements
     }
 
     public Object getAttribute(final String id) {
-        if (id == null) {
-            throw new IllegalArgumentException("Id may not be null");
-        }
+        Args.notNull(id, "Id");
         Object obj = null;
         if (this.map != null) {
             obj = this.map.get(id);
@@ -70,9 +69,7 @@ public class BasicHttpContext implements
     }
 
     public void setAttribute(final String id, final Object obj) {
-        if (id == null) {
-            throw new IllegalArgumentException("Id may not be null");
-        }
+        Args.notNull(id, "Id");
         if (this.map == null) {
             this.map = new HashMap<String, Object>();
         }
@@ -80,9 +77,7 @@ public class BasicHttpContext implements
     }
 
     public Object removeAttribute(final String id) {
-        if (id == null) {
-            throw new IllegalArgumentException("Id may not be null");
-        }
+        Args.notNull(id, "Id");
         if (this.map != null) {
             return this.map.remove(id);
         } else {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/BasicHttpProcessor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/BasicHttpProcessor.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/BasicHttpProcessor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/BasicHttpProcessor.java Wed Aug  8 19:56:38 2012
@@ -38,6 +38,7 @@ import org.apache.http.HttpRequestInterc
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseInterceptor;
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * Default implementation of {@link HttpProcessor}.
@@ -170,9 +171,7 @@ public final class BasicHttpProcessor im
      *                  from which to initialize
      */
     public void setInterceptors(final List<?> list) {
-        if (list == null) {
-            throw new IllegalArgumentException("List must not be null.");
-        }
+        Args.notNull(list, "Inteceptor list");
         this.requestInterceptors.clear();
         this.responseInterceptors.clear();
         for (int i = 0; i < list.size(); i++) {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/DefaultedHttpContext.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/DefaultedHttpContext.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/DefaultedHttpContext.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/DefaultedHttpContext.java Wed Aug  8 19:56:38 2012
@@ -28,6 +28,7 @@
 package org.apache.http.protocol;
 
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * {@link HttpContext} implementation that delegates resolution of an attribute
@@ -45,10 +46,7 @@ public final class DefaultedHttpContext 
 
     public DefaultedHttpContext(final HttpContext local, final HttpContext defaults) {
         super();
-        if (local == null) {
-            throw new IllegalArgumentException("HTTP context may not be null");
-        }
-        this.local = local;
+        this.local = Args.notNull(local, "HTTP context");
         this.defaults = defaults;
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java Wed Aug  8 19:56:38 2012
@@ -41,6 +41,7 @@ import org.apache.http.ProtocolException
 import org.apache.http.ProtocolVersion;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.params.CoreProtocolPNames;
+import org.apache.http.util.Args;
 
 /**
  * <tt>HttpRequestExecutor</tt> is a client side HTTP protocol handler based
@@ -109,18 +110,10 @@ public class HttpRequestExecutor {
     public HttpResponse execute(
             final HttpRequest request,
             final HttpClientConnection conn,
-            final HttpContext context)
-                throws IOException, HttpException {
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
-        if (conn == null) {
-            throw new IllegalArgumentException("Client connection may not be null");
-        }
-        if (context == null) {
-            throw new IllegalArgumentException("HTTP context may not be null");
-        }
-
+            final HttpContext context) throws IOException, HttpException {
+        Args.notNull(request, "HTTP request");
+        Args.notNull(conn, "Client connection");
+        Args.notNull(context, "HTTP context");
         try {
             HttpResponse response = doSendRequest(request, conn, context);
             if (response == null) {
@@ -161,17 +154,10 @@ public class HttpRequestExecutor {
     public void preProcess(
             final HttpRequest request,
             final HttpProcessor processor,
-            final HttpContext context)
-                throws HttpException, IOException {
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
-        if (processor == null) {
-            throw new IllegalArgumentException("HTTP processor may not be null");
-        }
-        if (context == null) {
-            throw new IllegalArgumentException("HTTP context may not be null");
-        }
+            final HttpContext context) throws HttpException, IOException {
+        Args.notNull(request, "HTTP request");
+        Args.notNull(processor, "HTTP processor");
+        Args.notNull(context, "HTTP context");
         context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
         processor.process(request, context);
     }
@@ -201,17 +187,10 @@ public class HttpRequestExecutor {
     protected HttpResponse doSendRequest(
             final HttpRequest request,
             final HttpClientConnection conn,
-            final HttpContext context)
-                throws IOException, HttpException {
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
-        if (conn == null) {
-            throw new IllegalArgumentException("HTTP connection may not be null");
-        }
-        if (context == null) {
-            throw new IllegalArgumentException("HTTP context may not be null");
-        }
+            final HttpContext context) throws IOException, HttpException {
+        Args.notNull(request, "HTTP request");
+        Args.notNull(conn, "Client connection");
+        Args.notNull(context, "HTTP context");
 
         HttpResponse response = null;
 
@@ -278,20 +257,12 @@ public class HttpRequestExecutor {
      *   problem.
      */
     protected HttpResponse doReceiveResponse(
-            final HttpRequest          request,
+            final HttpRequest request,
             final HttpClientConnection conn,
-            final HttpContext          context)
-                throws HttpException, IOException {
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
-        if (conn == null) {
-            throw new IllegalArgumentException("HTTP connection may not be null");
-        }
-        if (context == null) {
-            throw new IllegalArgumentException("HTTP context may not be null");
-        }
-
+            final HttpContext context) throws HttpException, IOException {
+        Args.notNull(request, "HTTP request");
+        Args.notNull(conn, "Client connection");
+        Args.notNull(context, "HTTP context");
         HttpResponse response = null;
         int statuscode = 0;
 
@@ -306,7 +277,6 @@ public class HttpRequestExecutor {
         } // while intermediate response
 
         return response;
-
     }
 
     /**
@@ -330,17 +300,10 @@ public class HttpRequestExecutor {
     public void postProcess(
             final HttpResponse response,
             final HttpProcessor processor,
-            final HttpContext context)
-                throws HttpException, IOException {
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
-        if (processor == null) {
-            throw new IllegalArgumentException("HTTP processor may not be null");
-        }
-        if (context == null) {
-            throw new IllegalArgumentException("HTTP context may not be null");
-        }
+            final HttpContext context) throws HttpException, IOException {
+        Args.notNull(response, "HTTP response");
+        Args.notNull(processor, "HTTP processor");
+        Args.notNull(context, "HTTP context");
         context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);
         processor.process(response, context);
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java Wed Aug  8 19:56:38 2012
@@ -30,6 +30,7 @@ package org.apache.http.protocol;
 import java.util.Map;
 
 import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * Maintains a map of HTTP request handlers keyed by a request URI pattern.
@@ -65,12 +66,8 @@ public class HttpRequestHandlerRegistry 
      * @param handler the handler.
      */
     public void register(final String pattern, final HttpRequestHandler handler) {
-        if (pattern == null) {
-            throw new IllegalArgumentException("URI request pattern may not be null");
-        }
-        if (handler == null) {
-            throw new IllegalArgumentException("Request handler may not be null");
-        }
+        Args.notNull(pattern, "URI request pattern");
+        Args.notNull(handler, "Request handler");
         matcher.register(pattern, handler);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java Wed Aug  8 19:56:38 2012
@@ -44,8 +44,9 @@ import org.apache.http.ProtocolException
 import org.apache.http.UnsupportedHttpVersionException;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.params.HttpParams;
 import org.apache.http.params.DefaultedHttpParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 import org.apache.http.util.EncodingUtils;
 import org.apache.http.util.EntityUtils;
 
@@ -101,24 +102,12 @@ public class HttpService {
             final HttpExpectationVerifier expectationVerifier,
             final HttpParams params) {
         super();
-        if (processor == null) {
-            throw new IllegalArgumentException("HTTP processor may not be null");
-        }
-        if (connStrategy == null) {
-            throw new IllegalArgumentException("Connection reuse strategy may not be null");
-        }
-        if (responseFactory == null) {
-            throw new IllegalArgumentException("Response factory may not be null");
-        }
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
-        this.processor = processor;
-        this.connStrategy = connStrategy;
-        this.responseFactory = responseFactory;
+        this.processor =  Args.notNull(processor, "HTTP processor");
+        this.connStrategy =  Args.notNull(connStrategy, "Connection reuse strategy");
+        this.responseFactory =  Args.notNull(responseFactory, "Response factory");
+        this.params = Args.notNull(params, "HTTP parameters");
         this.handlerResolver = handlerResolver;
         this.expectationVerifier = expectationVerifier;
-        this.params = params;
     }
 
     /**
@@ -167,9 +156,7 @@ public class HttpService {
      */
     @Deprecated
     public void setHttpProcessor(final HttpProcessor processor) {
-        if (processor == null) {
-            throw new IllegalArgumentException("HTTP processor may not be null");
-        }
+        Args.notNull(processor, "HTTP processor");
         this.processor = processor;
     }
 
@@ -178,9 +165,7 @@ public class HttpService {
      */
     @Deprecated
     public void setConnReuseStrategy(final ConnectionReuseStrategy connStrategy) {
-        if (connStrategy == null) {
-            throw new IllegalArgumentException("Connection reuse strategy may not be null");
-        }
+        Args.notNull(connStrategy, "Connection reuse strategy");
         this.connStrategy = connStrategy;
     }
 
@@ -189,9 +174,7 @@ public class HttpService {
      */
     @Deprecated
     public void setResponseFactory(final HttpResponseFactory responseFactory) {
-        if (responseFactory == null) {
-            throw new IllegalArgumentException("Response factory may not be null");
-        }
+        Args.notNull(responseFactory, "Response factory");
         this.responseFactory = responseFactory;
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestConnControl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestConnControl.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestConnControl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestConnControl.java Wed Aug  8 19:56:38 2012
@@ -33,6 +33,7 @@ import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 
 /**
  * RequestConnControl is responsible for adding <code>Connection</code> header
@@ -51,9 +52,7 @@ public class RequestConnControl implemen
 
     public void process(final HttpRequest request, final HttpContext context)
             throws HttpException, IOException {
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
+        Args.notNull(request, "HTTP request");
 
         String method = request.getRequestLine().getMethod();
         if (method.equalsIgnoreCase("CONNECT")) {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestContent.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestContent.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestContent.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestContent.java Wed Aug  8 19:56:38 2012
@@ -35,9 +35,10 @@ import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolVersion;
 import org.apache.http.ProtocolException;
+import org.apache.http.ProtocolVersion;
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 
 /**
  * RequestContent is the most important interceptor for outgoing requests.
@@ -81,9 +82,7 @@ public class RequestContent implements H
 
     public void process(final HttpRequest request, final HttpContext context)
             throws HttpException, IOException {
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
+        Args.notNull(request, "HTTP request");
         if (request instanceof HttpEntityEnclosingRequest) {
             if (this.overwrite) {
                 request.removeHeaders(HTTP.TRANSFER_ENCODING);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestDate.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestDate.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestDate.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestDate.java Wed Aug  8 19:56:38 2012
@@ -29,11 +29,12 @@ package org.apache.http.protocol;
 
 import java.io.IOException;
 
+import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
-import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * RequestDate interceptor is responsible for adding <code>Date</code> header
@@ -53,10 +54,7 @@ public class RequestDate implements Http
 
     public void process(final HttpRequest request, final HttpContext context)
             throws HttpException, IOException {
-        if (request == null) {
-            throw new IllegalArgumentException
-                ("HTTP request may not be null.");
-        }
+        Args.notNull(request, "HTTP request");
         if ((request instanceof HttpEntityEnclosingRequest) &&
             !request.containsHeader(HTTP.DATE_HEADER)) {
             String httpdate = DATE_GENERATOR.getCurrentDate();

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestExpectContinue.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestExpectContinue.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestExpectContinue.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestExpectContinue.java Wed Aug  8 19:56:38 2012
@@ -38,6 +38,7 @@ import org.apache.http.HttpVersion;
 import org.apache.http.ProtocolVersion;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.util.Args;
 
 /**
  * RequestExpectContinue is responsible for enabling the 'expect-continue'
@@ -61,9 +62,7 @@ public class RequestExpectContinue imple
 
     public void process(final HttpRequest request, final HttpContext context)
             throws HttpException, IOException {
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
+        Args.notNull(request, "HTTP request");
         if (request instanceof HttpEntityEnclosingRequest) {
             HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
             // Do not send the expect header if request body is known to be empty



Mime
View raw message