hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1370923 [3/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/HttpHost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpHost.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpHost.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HttpHost.java Wed Aug  8 19:56:38 2012
@@ -31,6 +31,7 @@ import java.io.Serializable;
 import java.util.Locale;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 import org.apache.http.util.LangUtils;
 
 /**
@@ -75,10 +76,7 @@ public final class HttpHost implements C
      */
     public HttpHost(final String hostname, int port, final String scheme) {
         super();
-        if (hostname == null) {
-            throw new IllegalArgumentException("Host name may not be null");
-        }
-        this.hostname   = hostname;
+        this.hostname   = Args.notNull(hostname, "Host name");
         this.lcHostname = hostname.toLowerCase(Locale.ENGLISH);
         if (scheme != null) {
             this.schemeName = scheme.toLowerCase(Locale.ENGLISH);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ProtocolVersion.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ProtocolVersion.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ProtocolVersion.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ProtocolVersion.java Wed Aug  8 19:56:38 2012
@@ -30,6 +30,7 @@ package org.apache.http;
 import java.io.Serializable;
 
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 
 /**
  * Represents a protocol version. The "major.minor" numbering
@@ -67,21 +68,9 @@ public class ProtocolVersion implements 
      * @param minor      the minor version number of the protocol
      */
     public ProtocolVersion(String protocol, int major, int minor) {
-        if (protocol == null) {
-            throw new IllegalArgumentException
-                ("Protocol name must not be null.");
-        }
-        if (major < 0) {
-            throw new IllegalArgumentException
-                ("Protocol major version number must not be negative.");
-        }
-        if (minor < 0) {
-            throw new IllegalArgumentException
-                ("Protocol minor version number may not be negative");
-        }
-        this.protocol = protocol;
-        this.major = major;
-        this.minor = minor;
+        this.protocol = Args.notNull(protocol, "Protocol name");
+        this.major = Args.notNegative(major, "Protocol minor version");
+        this.minor = Args.notNegative(minor, "Protocol minor version");;
     }
 
     /**
@@ -199,7 +188,7 @@ public class ProtocolVersion implements 
      * This method does <i>not</i> define a total ordering, as it would be
      * required for {@link java.lang.Comparable}.
      *
-     * @param that      the protocl version to compare with
+     * @param that      the protocol version to compare with
      *
      * @return   a negative integer, zero, or a positive integer
      *           as this version is less than, equal to, or greater than
@@ -210,16 +199,11 @@ public class ProtocolVersion implements 
      *         or if the argument is <code>null</code>
      */
     public int compareToVersion(ProtocolVersion that) {
-        if (that == null) {
-            throw new IllegalArgumentException
-                ("Protocol version must not be null.");
-        }
+        Args.notNull(that, "Protocol version");
         if (!this.protocol.equals(that.protocol)) {
-            throw new IllegalArgumentException
-                ("Versions for different protocols cannot be compared. " +
-                 this + " " + that);
+                throw new IllegalArgumentException("Versions for different protocols " +
+                		"cannot be compared. " + this + " " + that);
         }
-
         int delta = getMajor() - that.getMajor();
         if (delta == 0) {
             delta = getMinor() - that.getMinor();

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/UnsupportedHttpVersionException.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/UnsupportedHttpVersionException.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/UnsupportedHttpVersionException.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/UnsupportedHttpVersionException.java Wed Aug  8 19:56:38 2012
@@ -27,7 +27,6 @@
 
 package org.apache.http;
 
-import org.apache.http.ProtocolException;
 
 /**
  * Signals an unsupported version of the HTTP protocol.

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java Wed Aug  8 19:56:38 2012
@@ -32,6 +32,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * A generic streamed, non-repeatable entity that obtains its content
@@ -106,9 +107,7 @@ public class BasicHttpEntity extends Abs
     }
 
     public void writeTo(final OutputStream outstream) throws IOException {
-        if (outstream == null) {
-            throw new IllegalArgumentException("Output stream may not be null");
-        }
+        Args.notNull(outstream, "Output stream");
         InputStream instream = getContent();
         try {
             int l;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java Wed Aug  8 19:56:38 2012
@@ -34,6 +34,7 @@ import java.io.OutputStream;
 
 import org.apache.http.HttpEntity;
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 import org.apache.http.util.EntityUtils;
 
 /**
@@ -106,9 +107,7 @@ public class BufferedHttpEntity extends 
 
     @Override
     public void writeTo(final OutputStream outstream) throws IOException {
-        if (outstream == null) {
-            throw new IllegalArgumentException("Output stream may not be null");
-        }
+        Args.notNull(outstream, "Output stream");
         if (this.buffer != null) {
             outstream.write(this.buffer);
         } else {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java Wed Aug  8 19:56:38 2012
@@ -33,6 +33,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * A self contained, repeatable entity that obtains its content from a byte array.
@@ -55,9 +56,7 @@ public class ByteArrayEntity extends Abs
      */
     public ByteArrayEntity(final byte[] b, final ContentType contentType) {
         super();
-        if (b == null) {
-            throw new IllegalArgumentException("Source byte array may not be null");
-        }
+        Args.notNull(b, "Source byte array");
         this.content = b;
         this.b = b;
         this.off = 0;
@@ -72,9 +71,7 @@ public class ByteArrayEntity extends Abs
      */
     public ByteArrayEntity(final byte[] b, int off, int len, final ContentType contentType) {
         super();
-        if (b == null) {
-            throw new IllegalArgumentException("Source byte array may not be null");
-        }
+        Args.notNull(b, "Source byte array");
         if ((off < 0) || (off > b.length) || (len < 0) ||
                 ((off + len) < 0) || ((off + len) > b.length)) {
             throw new IndexOutOfBoundsException("off: " + off + " len: " + len + " b.length: " + b.length);
@@ -109,9 +106,7 @@ public class ByteArrayEntity extends Abs
     }
 
     public void writeTo(final OutputStream outstream) throws IOException {
-        if (outstream == null) {
-            throw new IllegalArgumentException("Output stream may not be null");
-        }
+        Args.notNull(outstream, "Output stream");
         outstream.write(this.b, this.off, this.len);
         outstream.flush();
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentType.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentType.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentType.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentType.java Wed Aug  8 19:56:38 2012
@@ -40,6 +40,7 @@ import org.apache.http.NameValuePair;
 import org.apache.http.ParseException;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.message.BasicHeaderValueParser;
+import org.apache.http.util.Args;
 
 /**
  * Content type information consisting of a MIME type and an optional charset.
@@ -142,16 +143,8 @@ public final class ContentType implement
      * @return content type
      */
     public static ContentType create(final String mimeType, final Charset charset) {
-        if (mimeType == null) {
-            throw new IllegalArgumentException("MIME type may not be null");
-        }
-        String type = mimeType.trim().toLowerCase(Locale.US);
-        if (type.length() == 0) {
-            throw new IllegalArgumentException("MIME type may not be empty");
-        }
-        if (!valid(type)) {
-            throw new IllegalArgumentException("MIME type may not contain reserved characters");
-        }
+        String type = Args.notEmpty(mimeType, "MIME type").trim().toLowerCase(Locale.US);
+        Args.check(valid(type), "MIME type may not contain reserved characters");
         return new ContentType(type, charset);
     }
 
@@ -200,9 +193,7 @@ public final class ContentType implement
      */
     public static ContentType parse(
             final String s) throws ParseException, UnsupportedCharsetException {
-        if (s == null) {
-            throw new IllegalArgumentException("Content type may not be null");
-        }
+        Args.notNull(s, "Content type");
         HeaderElement[] elements = BasicHeaderValueParser.parseElements(s, null);
         if (elements.length > 0) {
             return create(elements[0]);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/EntityTemplate.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/EntityTemplate.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/EntityTemplate.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/EntityTemplate.java Wed Aug  8 19:56:38 2012
@@ -33,6 +33,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import org.apache.http.util.Args;
+
 /**
  * Entity that delegates the process of content generation
  * to a {@link ContentProducer}.
@@ -45,10 +47,7 @@ public class EntityTemplate extends Abst
 
     public EntityTemplate(final ContentProducer contentproducer) {
         super();
-        if (contentproducer == null) {
-            throw new IllegalArgumentException("Content producer may not be null");
-        }
-        this.contentproducer = contentproducer;
+        this.contentproducer = Args.notNull(contentproducer, "Content producer");
     }
 
     public long getContentLength() {
@@ -66,9 +65,7 @@ public class EntityTemplate extends Abst
     }
 
     public void writeTo(final OutputStream outstream) throws IOException {
-        if (outstream == null) {
-            throw new IllegalArgumentException("Output stream may not be null");
-        }
+        Args.notNull(outstream, "Output stream");
         this.contentproducer.writeTo(outstream);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/FileEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/FileEntity.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/FileEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/FileEntity.java Wed Aug  8 19:56:38 2012
@@ -34,6 +34,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * A self contained, repeatable entity that obtains its content from a file.
@@ -51,10 +52,7 @@ public class FileEntity extends Abstract
     @Deprecated
     public FileEntity(final File file, final String contentType) {
         super();
-        if (file == null) {
-            throw new IllegalArgumentException("File may not be null");
-        }
-        this.file = file;
+        this.file = Args.notNull(file, "File");
         setContentType(contentType);
     }
 
@@ -63,10 +61,7 @@ public class FileEntity extends Abstract
      */
     public FileEntity(final File file, final ContentType contentType) {
         super();
-        if (file == null) {
-            throw new IllegalArgumentException("File may not be null");
-        }
-        this.file = file;
+        this.file = Args.notNull(file, "File");
         if (contentType != null) {
             setContentType(contentType.toString());
         }
@@ -77,10 +72,7 @@ public class FileEntity extends Abstract
      */
     public FileEntity(final File file) {
         super();
-        if (file == null) {
-            throw new IllegalArgumentException("File may not be null");
-        }
-        this.file = file;
+        this.file = Args.notNull(file, "File");
     }
 
     public boolean isRepeatable() {
@@ -96,9 +88,7 @@ public class FileEntity extends Abstract
     }
 
     public void writeTo(final OutputStream outstream) throws IOException {
-        if (outstream == null) {
-            throw new IllegalArgumentException("Output stream may not be null");
-        }
+        Args.notNull(outstream, "Output stream");
         InputStream instream = new FileInputStream(this.file);
         try {
             byte[] tmp = new byte[4096];

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java Wed Aug  8 19:56:38 2012
@@ -34,6 +34,7 @@ import java.io.OutputStream;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * Base class for wrapping entities.
@@ -56,18 +57,11 @@ public class HttpEntityWrapper implement
      * @param wrapped   the entity to wrap, not null
      * @throws IllegalArgumentException if wrapped is null
      */
-    public HttpEntityWrapper(HttpEntity wrapped) {
+    public HttpEntityWrapper(HttpEntity wrappedEntity) {
         super();
-
-        if (wrapped == null) {
-            throw new IllegalArgumentException
-                ("wrapped entity must not be null");
-        }
-        wrappedEntity = wrapped;
-
+        this.wrappedEntity = Args.notNull(wrappedEntity, "Wrapped entity");
     } // constructor
 
-
     public boolean isRepeatable() {
         return wrappedEntity.isRepeatable();
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java Wed Aug  8 19:56:38 2012
@@ -32,6 +32,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * A streamed, non-repeatable entity that obtains its content from
@@ -56,10 +57,7 @@ public class InputStreamEntity extends A
      */
     public InputStreamEntity(final InputStream instream, long length, final ContentType contentType) {
         super();
-        if (instream == null) {
-            throw new IllegalArgumentException("Source input stream may not be null");
-        }
-        this.content = instream;
+        this.content = Args.notNull(instream, "Source input stream");
         this.length = length;
         if (contentType != null) {
             setContentType(contentType.toString());
@@ -79,9 +77,7 @@ public class InputStreamEntity extends A
     }
 
     public void writeTo(final OutputStream outstream) throws IOException {
-        if (outstream == null) {
-            throw new IllegalArgumentException("Output stream may not be null");
-        }
+        Args.notNull(outstream, "Output stream");
         InputStream instream = this.content;
         try {
             byte[] buffer = new byte[BUFFER_SIZE];

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java Wed Aug  8 19:56:38 2012
@@ -36,6 +36,7 @@ import java.io.OutputStream;
 import java.io.Serializable;
 
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 
 /**
  * A streamed entity that obtains its content from a {@link Serializable}.
@@ -62,10 +63,7 @@ public class SerializableEntity extends 
      */
     public SerializableEntity(Serializable ser, boolean bufferize) throws IOException {
         super();
-        if (ser == null) {
-            throw new IllegalArgumentException("Source object may not be null");
-        }
-
+        Args.notNull(ser, "Source object");
         if (bufferize) {
             createBytes(ser);
         } else {
@@ -105,10 +103,7 @@ public class SerializableEntity extends 
     }
 
     public void writeTo(OutputStream outstream) throws IOException {
-        if (outstream == null) {
-            throw new IllegalArgumentException("Output stream may not be null");
-        }
-
+        Args.notNull(outstream, "Output stream");
         if (this.objSer == null) {
             ObjectOutputStream out = new ObjectOutputStream(outstream);
             out.writeObject(this.objRef);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java Wed Aug  8 19:56:38 2012
@@ -37,6 +37,7 @@ import java.nio.charset.UnsupportedChars
 
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.protocol.HTTP;
+import org.apache.http.util.Args;
 
 /**
  * A self contained, repeatable entity that obtains its content from
@@ -62,9 +63,7 @@ public class StringEntity extends Abstra
      */
     public StringEntity(final String string, final ContentType contentType) {
         super();
-        if (string == null) {
-            throw new IllegalArgumentException("Source string may not be null");
-        }
+        Args.notNull(string, "Source string");
         Charset charset = contentType != null ? contentType.getCharset() : null;
         if (charset == null) {
             charset = HTTP.DEF_CONTENT_CHARSET;
@@ -98,9 +97,7 @@ public class StringEntity extends Abstra
     public StringEntity(final String string, String mimeType, String charset)
             throws UnsupportedEncodingException {
         super();
-        if (string == null) {
-            throw new IllegalArgumentException("Source string may not be null");
-        }
+        Args.notNull(string, "Source string");
         if (mimeType == null) {
             mimeType = HTTP.PLAIN_TEXT_TYPE;
         }
@@ -170,9 +167,7 @@ public class StringEntity extends Abstra
     }
 
     public void writeTo(final OutputStream outstream) throws IOException {
-        if (outstream == null) {
-            throw new IllegalArgumentException("Output stream may not be null");
-        }
+        Args.notNull(outstream, "Output stream");
         outstream.write(this.content);
         outstream.flush();
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java Wed Aug  8 19:56:38 2012
@@ -55,6 +55,7 @@ import org.apache.http.io.SessionOutputB
 import org.apache.http.message.LineFormatter;
 import org.apache.http.message.LineParser;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 
 /**
  * Abstract client-side HTTP connection capable of transmitting and receiving
@@ -218,14 +219,8 @@ public abstract class AbstractHttpClient
             final SessionInputBuffer inbuffer,
             final SessionOutputBuffer outbuffer,
             final HttpParams params) {
-        if (inbuffer == null) {
-            throw new IllegalArgumentException("Input session buffer may not be null");
-        }
-        if (outbuffer == null) {
-            throw new IllegalArgumentException("Output session buffer may not be null");
-        }
-        this.inbuffer = inbuffer;
-        this.outbuffer = outbuffer;
+        this.inbuffer = Args.notNull(inbuffer, "Input session buffer");
+        this.outbuffer = Args.notNull(outbuffer, "Output session buffer");
         if (inbuffer instanceof EofSensor) {
             this.eofSensor = (EofSensor) inbuffer;
         }
@@ -251,9 +246,7 @@ public abstract class AbstractHttpClient
 
     public void sendRequestHeader(final HttpRequest request)
             throws HttpException, IOException {
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
+        Args.notNull(request, "HTTP request");
         assertOpen();
         this.requestWriter.write(request);
         this.metrics.incrementRequestCount();
@@ -261,9 +254,7 @@ public abstract class AbstractHttpClient
 
     public void sendRequestEntity(final HttpEntityEnclosingRequest request)
             throws HttpException, IOException {
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
+        Args.notNull(request, "HTTP request");
         assertOpen();
         if (request.getEntity() == null) {
             return;
@@ -295,9 +286,7 @@ public abstract class AbstractHttpClient
 
     public void receiveResponseEntity(final HttpResponse response)
             throws HttpException, IOException {
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
+        Args.notNull(response, "HTTP response");
         assertOpen();
         HttpEntity entity = this.entitydeserializer.deserialize(this.inbuffer, response);
         response.setEntity(entity);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java Wed Aug  8 19:56:38 2012
@@ -55,6 +55,7 @@ import org.apache.http.io.SessionOutputB
 import org.apache.http.message.LineFormatter;
 import org.apache.http.message.LineParser;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 
 /**
  * Abstract server-side HTTP connection capable of transmitting and receiving
@@ -219,14 +220,8 @@ public abstract class AbstractHttpServer
             final SessionInputBuffer inbuffer,
             final SessionOutputBuffer outbuffer,
             final HttpParams params) {
-        if (inbuffer == null) {
-            throw new IllegalArgumentException("Input session buffer may not be null");
-        }
-        if (outbuffer == null) {
-            throw new IllegalArgumentException("Output session buffer may not be null");
-        }
-        this.inbuffer = inbuffer;
-        this.outbuffer = outbuffer;
+        this.inbuffer = Args.notNull(inbuffer, "Input session buffer");
+        this.outbuffer = Args.notNull(outbuffer, "Output session buffer");
         if (inbuffer instanceof EofSensor) {
             this.eofSensor = (EofSensor) inbuffer;
         }
@@ -251,9 +246,7 @@ public abstract class AbstractHttpServer
 
     public void receiveRequestEntity(final HttpEntityEnclosingRequest request)
             throws HttpException, IOException {
-        if (request == null) {
-            throw new IllegalArgumentException("HTTP request may not be null");
-        }
+        Args.notNull(request, "HTTP request");
         assertOpen();
         HttpEntity entity = this.entitydeserializer.deserialize(this.inbuffer, request);
         request.setEntity(entity);
@@ -270,9 +263,7 @@ public abstract class AbstractHttpServer
 
     public void sendResponseHeader(final HttpResponse response)
             throws HttpException, IOException {
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
+        Args.notNull(response, "HTTP response");
         assertOpen();
         this.responseWriter.write(response);
         if (response.getStatusLine().getStatusCode() >= 200) {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java Wed Aug  8 19:56:38 2012
@@ -34,11 +34,12 @@ import org.apache.http.HttpResponse;
 import org.apache.http.HttpVersion;
 import org.apache.http.ParseException;
 import org.apache.http.ProtocolVersion;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
 import org.apache.http.TokenIterator;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.message.BasicTokenIterator;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
 
 /**
  * Default implementation of a strategy deciding about connection re-use.
@@ -70,12 +71,8 @@ public class DefaultConnectionReuseStrat
     // see interface ConnectionReuseStrategy
     public boolean keepAlive(final HttpResponse response,
                              final HttpContext context) {
-        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(response, "HTTP response");
+        Args.notNull(context, "HTTP context");
 
         // Check for a self-terminating entity. If the end of the entity will
         // be indicated by closing the connection, there is no keep-alive.

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java Wed Aug  8 19:56:38 2012
@@ -33,6 +33,7 @@ import java.net.Socket;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 
 /**
  * Default implementation of a client-side HTTP connection.
@@ -64,12 +65,8 @@ public class DefaultHttpClientConnection
     public void bind(
             final Socket socket,
             final HttpParams params) throws IOException {
-        if (socket == null) {
-            throw new IllegalArgumentException("Socket may not be null");
-        }
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(socket, "Socket");
+        Args.notNull(params, "HTTP parameters");
         assertNotOpen();
         socket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
         socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params));

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpRequestFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpRequestFactory.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpRequestFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpRequestFactory.java Wed Aug  8 19:56:38 2012
@@ -34,6 +34,7 @@ import org.apache.http.RequestLine;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.message.BasicHttpEntityEnclosingRequest;
 import org.apache.http.message.BasicHttpRequest;
+import org.apache.http.util.Args;
 
 /**
  * Default factory for creating {@link HttpRequest} objects.
@@ -78,9 +79,7 @@ public class DefaultHttpRequestFactory i
 
     public HttpRequest newHttpRequest(final RequestLine requestline)
             throws MethodNotSupportedException {
-        if (requestline == null) {
-            throw new IllegalArgumentException("Request line may not be null");
-        }
+        Args.notNull(requestline, "Request line");
         String method = requestline.getMethod();
         if (isOneOf(RFC2616_COMMON_METHODS, method)) {
             return new BasicHttpRequest(requestline);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpResponseFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpResponseFactory.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpResponseFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpResponseFactory.java Wed Aug  8 19:56:38 2012
@@ -32,13 +32,13 @@ import java.util.Locale;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.ProtocolVersion;
+import org.apache.http.ReasonPhraseCatalog;
 import org.apache.http.StatusLine;
+import org.apache.http.annotation.Immutable;
 import org.apache.http.message.BasicHttpResponse;
 import org.apache.http.message.BasicStatusLine;
 import org.apache.http.protocol.HttpContext;
-import org.apache.http.ReasonPhraseCatalog;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.impl.EnglishReasonPhraseCatalog;
+import org.apache.http.util.Args;
 
 /**
  * Default factory for creating {@link HttpResponse} objects.
@@ -60,11 +60,7 @@ public class DefaultHttpResponseFactory 
      * @param catalog   the catalog of reason phrases
      */
     public DefaultHttpResponseFactory(ReasonPhraseCatalog catalog) {
-        if (catalog == null) {
-            throw new IllegalArgumentException
-                ("Reason phrase catalog must not be null.");
-        }
-        this.reasonCatalog = catalog;
+        this.reasonCatalog = Args.notNull(catalog, "Reason phrase catalog");
     }
 
     /**
@@ -80,11 +76,9 @@ public class DefaultHttpResponseFactory 
     public HttpResponse newHttpResponse(final ProtocolVersion ver,
                                         final int status,
                                         HttpContext context) {
-        if (ver == null) {
-            throw new IllegalArgumentException("HTTP version may not be null");
-        }
-        final Locale loc      = determineLocale(context);
-        final String reason   = reasonCatalog.getReason(status, loc);
+        Args.notNull(ver, "HTTP version");
+        Locale loc = determineLocale(context);
+        String reason   = reasonCatalog.getReason(status, loc);
         StatusLine statusline = new BasicStatusLine(ver, status, reason);
         return new BasicHttpResponse(statusline, reasonCatalog, loc);
     }
@@ -93,9 +87,7 @@ public class DefaultHttpResponseFactory 
     // non-javadoc, see interface HttpResponseFactory
     public HttpResponse newHttpResponse(final StatusLine statusline,
                                         HttpContext context) {
-        if (statusline == null) {
-            throw new IllegalArgumentException("Status line may not be null");
-        }
+        Args.notNull(statusline, "Status line");
         final Locale loc = determineLocale(context);
         return new BasicHttpResponse(statusline, reasonCatalog, loc);
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java Wed Aug  8 19:56:38 2012
@@ -33,6 +33,7 @@ import java.net.Socket;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 
 /**
  * Default implementation of a server-side HTTP connection.
@@ -62,12 +63,8 @@ public class DefaultHttpServerConnection
 
     @Override
     public void bind(final Socket socket, final HttpParams params) throws IOException {
-        if (socket == null) {
-            throw new IllegalArgumentException("Socket may not be null");
-        }
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(socket, "Socket");
+        Args.notNull(params, "HTTP parameters");
         assertNotOpen();
         socket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
         socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params));

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/EnglishReasonPhraseCatalog.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/EnglishReasonPhraseCatalog.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/EnglishReasonPhraseCatalog.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/EnglishReasonPhraseCatalog.java Wed Aug  8 19:56:38 2012
@@ -32,6 +32,7 @@ import java.util.Locale;
 import org.apache.http.HttpStatus;
 import org.apache.http.ReasonPhraseCatalog;
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 
 /**
  * English reason phrases for HTTP status codes.
@@ -72,13 +73,9 @@ public class EnglishReasonPhraseCatalog 
      * @return  the reason phrase, or <code>null</code>
      */
     public String getReason(int status, Locale loc) {
-        if ((status < 100) || (status >= 600)) {
-            throw new IllegalArgumentException
-                ("Unknown category for status code " + status + ".");
-        }
-
-        final int category = status / 100;
-        final int subcode  = status - 100*category;
+        Args.check(status >= 100 && status < 600, "Unknown category for status code " + status);
+        int category = status / 100;
+        int subcode  = status - 100*category;
 
         String reason = null;
         if (REASON_PHRASES[category].length > subcode)

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/NoConnectionReuseStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/NoConnectionReuseStrategy.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/NoConnectionReuseStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/NoConnectionReuseStrategy.java Wed Aug  8 19:56:38 2012
@@ -47,13 +47,6 @@ public class NoConnectionReuseStrategy i
     }
 
     public boolean keepAlive(final HttpResponse response, final HttpContext context) {
-        if (response == null) {
-            throw new IllegalArgumentException("HTTP response may not be null");
-        }
-        if (context == null) {
-            throw new IllegalArgumentException("HTTP context may not be null");
-        }
-
         return false;
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java Wed Aug  8 19:56:38 2012
@@ -42,6 +42,7 @@ import org.apache.http.io.SessionInputBu
 import org.apache.http.io.SessionOutputBuffer;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 
 /**
  * Implementation of a client-side HTTP connection that can be bound to an
@@ -150,12 +151,8 @@ public class SocketHttpClientConnection
     protected void bind(
             final Socket socket,
             final HttpParams params) throws IOException {
-        if (socket == null) {
-            throw new IllegalArgumentException("Socket may not be null");
-        }
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(socket, "Socket");
+        Args.notNull(params, "HTTP parameters");
         this.socket = socket;
 
         int buffersize = HttpConnectionParams.getSocketBufferSize(params);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java Wed Aug  8 19:56:38 2012
@@ -42,6 +42,7 @@ import org.apache.http.io.SessionInputBu
 import org.apache.http.io.SessionOutputBuffer;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 
 /**
  * Implementation of a server-side HTTP connection that can be bound to a
@@ -147,12 +148,8 @@ public class SocketHttpServerConnection 
      * @throws IOException in case of an I/O error.
      */
     protected void bind(final Socket socket, final HttpParams params) throws IOException {
-        if (socket == null) {
-            throw new IllegalArgumentException("Socket may not be null");
-        }
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(socket, "Socket");
+        Args.notNull(params, "HTTP parameters");
         this.socket = socket;
 
         int buffersize = HttpConnectionParams.getSocketBufferSize(params);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/EntityDeserializer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/EntityDeserializer.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/EntityDeserializer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/EntityDeserializer.java Wed Aug  8 19:56:38 2012
@@ -41,6 +41,7 @@ import org.apache.http.impl.io.ContentLe
 import org.apache.http.impl.io.IdentityInputStream;
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.protocol.HTTP;
+import org.apache.http.util.Args;
 
 /**
  * HTTP entity deserializer.
@@ -65,10 +66,7 @@ public class EntityDeserializer {
 
     public EntityDeserializer(final ContentLengthStrategy lenStrategy) {
         super();
-        if (lenStrategy == null) {
-            throw new IllegalArgumentException("Content length strategy may not be null");
-        }
-        this.lenStrategy = lenStrategy;
+        this.lenStrategy = Args.notNull(lenStrategy, "Content length strategy");
     }
 
     /**
@@ -134,12 +132,8 @@ public class EntityDeserializer {
     public HttpEntity deserialize(
             final SessionInputBuffer inbuffer,
             final HttpMessage message) throws HttpException, IOException {
-        if (inbuffer == null) {
-            throw new IllegalArgumentException("Session input buffer may not be null");
-        }
-        if (message == null) {
-            throw new IllegalArgumentException("HTTP message may not be null");
-        }
+        Args.notNull(inbuffer, "Session input buffer");
+        Args.notNull(message, "HTTP message");
         return doDeserialize(inbuffer, message);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/EntitySerializer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/EntitySerializer.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/EntitySerializer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/EntitySerializer.java Wed Aug  8 19:56:38 2012
@@ -39,6 +39,7 @@ import org.apache.http.impl.io.ChunkedOu
 import org.apache.http.impl.io.ContentLengthOutputStream;
 import org.apache.http.impl.io.IdentityOutputStream;
 import org.apache.http.io.SessionOutputBuffer;
+import org.apache.http.util.Args;
 
 /**
  * HTTP entity serializer.
@@ -62,10 +63,7 @@ public class EntitySerializer {
 
     public EntitySerializer(final ContentLengthStrategy lenStrategy) {
         super();
-        if (lenStrategy == null) {
-            throw new IllegalArgumentException("Content length strategy may not be null");
-        }
-        this.lenStrategy = lenStrategy;
+        this.lenStrategy = Args.notNull(lenStrategy, "Content length strategy");
     }
 
     /**
@@ -109,15 +107,9 @@ public class EntitySerializer {
             final SessionOutputBuffer outbuffer,
             final HttpMessage message,
             final HttpEntity entity) throws HttpException, IOException {
-        if (outbuffer == null) {
-            throw new IllegalArgumentException("Session output buffer may not be null");
-        }
-        if (message == null) {
-            throw new IllegalArgumentException("HTTP message may not be null");
-        }
-        if (entity == null) {
-            throw new IllegalArgumentException("HTTP entity may not be null");
-        }
+        Args.notNull(outbuffer, "Session output buffer");
+        Args.notNull(message, "HTTP message");
+        Args.notNull(entity, "HTTP entity");
         OutputStream outstream = doSerialize(outbuffer, message);
         entity.writeTo(outstream);
         outstream.close();

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java Wed Aug  8 19:56:38 2012
@@ -35,9 +35,10 @@ import org.apache.http.ParseException;
 import org.apache.http.ProtocolException;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.entity.ContentLengthStrategy;
-import org.apache.http.params.HttpParams;
 import org.apache.http.params.CoreProtocolPNames;
+import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HTTP;
+import org.apache.http.util.Args;
 
 /**
  * The lax implementation of the content length strategy. This class will ignore
@@ -81,10 +82,7 @@ public class LaxContentLengthStrategy im
     }
 
     public long determineLength(final HttpMessage message) throws HttpException {
-        if (message == null) {
-            throw new IllegalArgumentException("HTTP message may not be null");
-        }
-
+        Args.notNull(message, "HTTP message");
         HttpParams params = message.getParams();
         boolean strict = params.isParameterTrue(CoreProtocolPNames.STRICT_TRANSFER_ENCODING);
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/StrictContentLengthStrategy.java Wed Aug  8 19:56:38 2012
@@ -35,6 +35,7 @@ import org.apache.http.ProtocolException
 import org.apache.http.annotation.Immutable;
 import org.apache.http.entity.ContentLengthStrategy;
 import org.apache.http.protocol.HTTP;
+import org.apache.http.util.Args;
 
 /**
  * The strict implementation of the content length strategy. This class
@@ -73,9 +74,7 @@ public class StrictContentLengthStrategy
     }
 
     public long determineLength(final HttpMessage message) throws HttpException {
-        if (message == null) {
-            throw new IllegalArgumentException("HTTP message may not be null");
-        }
+        Args.notNull(message, "HTTP message");
         // Although Transfer-Encoding is specified as a list, in practice
         // it is either missing or has the single value "chunked". So we
         // treat it as a single-valued header here.

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java Wed Aug  8 19:56:38 2012
@@ -39,10 +39,11 @@ import org.apache.http.ProtocolException
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.HttpMessageParser;
 import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.message.LineParser;
 import org.apache.http.message.BasicLineParser;
+import org.apache.http.message.LineParser;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -85,12 +86,8 @@ public abstract class AbstractMessagePar
             final LineParser parser,
             final HttpParams params) {
         super();
-        if (buffer == null) {
-            throw new IllegalArgumentException("Session input buffer may not be null");
-        }
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(buffer, "Session input buffer");
+        Args.notNull(params, "HTTP parameters");
         this.sessionBuffer = buffer;
         this.maxHeaderCount = params.getIntParameter(
                 CoreConnectionPNames.MAX_HEADER_COUNT, -1);
@@ -162,18 +159,10 @@ public abstract class AbstractMessagePar
             int maxHeaderCount,
             int maxLineLen,
             final LineParser parser,
-            final List<CharArrayBuffer> headerLines)
-        throws HttpException, IOException {
-
-        if (inbuffer == null) {
-            throw new IllegalArgumentException("Session input buffer may not be null");
-        }
-        if (parser == null) {
-            throw new IllegalArgumentException("Line parser may not be null");
-        }
-        if (headerLines == null) {
-            throw new IllegalArgumentException("Header line list may not be null");
-        }
+            final List<CharArrayBuffer> headerLines) throws HttpException, IOException {
+        Args.notNull(inbuffer, "Session input buffer");
+        Args.notNull(parser, "Line parser");
+        Args.notNull(headerLines, "Header line list");
 
         CharArrayBuffer current = null;
         CharArrayBuffer previous = null;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageWriter.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageWriter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageWriter.java Wed Aug  8 19:56:38 2012
@@ -36,9 +36,10 @@ import org.apache.http.HttpMessage;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.HttpMessageWriter;
 import org.apache.http.io.SessionOutputBuffer;
-import org.apache.http.message.LineFormatter;
 import org.apache.http.message.BasicLineFormatter;
+import org.apache.http.message.LineFormatter;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -65,9 +66,7 @@ public abstract class AbstractMessageWri
                                  final LineFormatter formatter,
                                  final HttpParams params) {
         super();
-        if (buffer == null) {
-            throw new IllegalArgumentException("Session input buffer may not be null");
-        }
+        Args.notNull(buffer, "Session input buffer");
         this.sessionBuffer = buffer;
         this.lineBuf = new CharArrayBuffer(128);
         this.lineFormatter = (formatter != null) ? formatter : BasicLineFormatter.INSTANCE;
@@ -83,9 +82,7 @@ public abstract class AbstractMessageWri
     protected abstract void writeHeadLine(T message) throws IOException;
 
     public void write(final T message) throws IOException, HttpException {
-        if (message == null) {
-            throw new IllegalArgumentException("HTTP message may not be null");
-        }
+        Args.notNull(message, "HTTP message");
         writeHeadLine(message);
         for (HeaderIterator it = message.headerIterator(); it.hasNext(); ) {
             Header header = it.nextHeader();

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractSessionInputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractSessionInputBuffer.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractSessionInputBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractSessionInputBuffer.java Wed Aug  8 19:56:38 2012
@@ -38,12 +38,13 @@ import java.nio.charset.CodingErrorActio
 
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.BufferInfo;
-import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.io.HttpTransportMetrics;
+import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.HTTP;
+import org.apache.http.util.Args;
 import org.apache.http.util.ByteArrayBuffer;
 import org.apache.http.util.CharArrayBuffer;
 
@@ -98,15 +99,9 @@ public abstract class AbstractSessionInp
      * @param params HTTP parameters.
      */
     protected void init(final InputStream instream, int buffersize, final HttpParams params) {
-        if (instream == null) {
-            throw new IllegalArgumentException("Input stream may not be null");
-        }
-        if (buffersize <= 0) {
-            throw new IllegalArgumentException("Buffer size may not be negative or zero");
-        }
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(instream, "Input stream");
+        Args.notNegative(buffersize, "Buffer size");
+        Args.notNull(params, "HTTP parameters");
         this.instream = instream;
         this.buffer = new byte[buffersize];
         this.bufferpos = 0;
@@ -253,9 +248,7 @@ public abstract class AbstractSessionInp
      * @exception  IOException  if an I/O error occurs.
      */
     public int readLine(final CharArrayBuffer charbuffer) throws IOException {
-        if (charbuffer == null) {
-            throw new IllegalArgumentException("Char array buffer may not be null");
-        }
+        Args.notNull(charbuffer, "Char array buffer");
         int noRead = 0;
         boolean retry = true;
         while (retry) {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractSessionOutputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractSessionOutputBuffer.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractSessionOutputBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/AbstractSessionOutputBuffer.java Wed Aug  8 19:56:38 2012
@@ -38,12 +38,13 @@ import java.nio.charset.CodingErrorActio
 
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.BufferInfo;
-import org.apache.http.io.SessionOutputBuffer;
 import org.apache.http.io.HttpTransportMetrics;
+import org.apache.http.io.SessionOutputBuffer;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.HTTP;
+import org.apache.http.util.Args;
 import org.apache.http.util.ByteArrayBuffer;
 import org.apache.http.util.CharArrayBuffer;
 
@@ -93,15 +94,9 @@ public abstract class AbstractSessionOut
      * @param params HTTP parameters.
      */
     protected void init(final OutputStream outstream, int buffersize, final HttpParams params) {
-        if (outstream == null) {
-            throw new IllegalArgumentException("Input stream may not be null");
-        }
-        if (buffersize <= 0) {
-            throw new IllegalArgumentException("Buffer size may not be negative or zero");
-        }
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        Args.notNull(outstream, "Input stream");
+        Args.notNegative(buffersize, "Buffer size");
+        Args.notNull(params, "HTTP parameters");
         this.outstream = outstream;
         this.buffer = new ByteArrayBuffer(buffersize);
         this.charset = Charset.forName(HttpProtocolParams.getHttpElementCharset(params));

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java Wed Aug  8 19:56:38 2012
@@ -37,6 +37,7 @@ import org.apache.http.TruncatedChunkExc
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.BufferInfo;
 import org.apache.http.io.SessionInputBuffer;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -92,10 +93,7 @@ public class ChunkedInputStream extends 
      */
     public ChunkedInputStream(final SessionInputBuffer in) {
         super();
-        if (in == null) {
-            throw new IllegalArgumentException("Session input buffer may not be null");
-        }
-        this.in = in;
+        this.in = Args.notNull(in, "Session input buffer");
         this.pos = 0;
         this.buffer = new CharArrayBuffer(16);
         this.state = CHUNK_LEN;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java Wed Aug  8 19:56:38 2012
@@ -34,6 +34,7 @@ import org.apache.http.ConnectionClosedE
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.BufferInfo;
 import org.apache.http.io.SessionInputBuffer;
+import org.apache.http.util.Args;
 
 /**
  * Input stream that cuts off after a defined number of bytes. This class
@@ -82,14 +83,8 @@ public class ContentLengthInputStream ex
      */
     public ContentLengthInputStream(final SessionInputBuffer in, long contentLength) {
         super();
-        if (in == null) {
-            throw new IllegalArgumentException("Input stream may not be null");
-        }
-        if (contentLength < 0) {
-            throw new IllegalArgumentException("Content length may not be negative");
-        }
-        this.in = in;
-        this.contentLength = contentLength;
+        this.in = Args.notNull(in, "Session input buffer");
+        this.contentLength = Args.notNegative(contentLength, "Content length");
     }
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthOutputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthOutputStream.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthOutputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthOutputStream.java Wed Aug  8 19:56:38 2012
@@ -32,6 +32,7 @@ import java.io.OutputStream;
 
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.SessionOutputBuffer;
+import org.apache.http.util.Args;
 
 /**
  * Output stream that cuts off after a defined number of bytes. This class
@@ -78,14 +79,8 @@ public class ContentLengthOutputStream e
      */
     public ContentLengthOutputStream(final SessionOutputBuffer out, long contentLength) {
         super();
-        if (out == null) {
-            throw new IllegalArgumentException("Session output buffer may not be null");
-        }
-        if (contentLength < 0) {
-            throw new IllegalArgumentException("Content length may not be negative");
-        }
-        this.out = out;
-        this.contentLength = contentLength;
+        this.out = Args.notNull(out, "Session output buffer");
+        this.contentLength = Args.notNegative(contentLength, "Content length");
     }
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpRequestParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpRequestParser.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpRequestParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpRequestParser.java Wed Aug  8 19:56:38 2012
@@ -33,13 +33,14 @@ import org.apache.http.ConnectionClosedE
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestFactory;
-import org.apache.http.RequestLine;
 import org.apache.http.ParseException;
+import org.apache.http.RequestLine;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.message.LineParser;
 import org.apache.http.message.ParserCursor;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -76,10 +77,7 @@ public class DefaultHttpRequestParser ex
             final HttpRequestFactory requestFactory,
             final HttpParams params) {
         super(buffer, parser, params);
-        if (requestFactory == null) {
-            throw new IllegalArgumentException("Request factory may not be null");
-        }
-        this.requestFactory = requestFactory;
+        this.requestFactory = Args.notNull(requestFactory, "Request factory");
         this.lineBuf = new CharArrayBuffer(128);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpResponseParser.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpResponseParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpResponseParser.java Wed Aug  8 19:56:38 2012
@@ -33,13 +33,14 @@ import org.apache.http.HttpException;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.NoHttpResponseException;
-import org.apache.http.StatusLine;
 import org.apache.http.ParseException;
+import org.apache.http.StatusLine;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.message.LineParser;
 import org.apache.http.message.ParserCursor;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -76,10 +77,7 @@ public class DefaultHttpResponseParser e
             final HttpResponseFactory responseFactory,
             final HttpParams params) {
         super(buffer, parser, params);
-        if (responseFactory == null) {
-            throw new IllegalArgumentException("Response factory may not be null");
-        }
-        this.responseFactory = responseFactory;
+        this.responseFactory = Args.notNull(responseFactory, "Response factory");
         this.lineBuf = new CharArrayBuffer(128);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestParser.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpRequestParser.java Wed Aug  8 19:56:38 2012
@@ -34,13 +34,14 @@ import org.apache.http.HttpException;
 import org.apache.http.HttpMessage;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestFactory;
-import org.apache.http.RequestLine;
 import org.apache.http.ParseException;
+import org.apache.http.RequestLine;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.message.LineParser;
 import org.apache.http.message.ParserCursor;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -80,10 +81,7 @@ public class HttpRequestParser extends A
             final HttpRequestFactory requestFactory,
             final HttpParams params) {
         super(buffer, parser, params);
-        if (requestFactory == null) {
-            throw new IllegalArgumentException("Request factory may not be null");
-        }
-        this.requestFactory = requestFactory;
+        this.requestFactory = Args.notNull(requestFactory, "Request factory");
         this.lineBuf = new CharArrayBuffer(128);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseParser.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/HttpResponseParser.java Wed Aug  8 19:56:38 2012
@@ -34,13 +34,14 @@ import org.apache.http.HttpMessage;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.NoHttpResponseException;
-import org.apache.http.StatusLine;
 import org.apache.http.ParseException;
+import org.apache.http.StatusLine;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.message.LineParser;
 import org.apache.http.message.ParserCursor;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -80,10 +81,7 @@ public class HttpResponseParser extends 
             final HttpResponseFactory responseFactory,
             final HttpParams params) {
         super(buffer, parser, params);
-        if (responseFactory == null) {
-            throw new IllegalArgumentException("Response factory may not be null");
-        }
-        this.responseFactory = responseFactory;
+        this.responseFactory = Args.notNull(responseFactory, "Response factory");
         this.lineBuf = new CharArrayBuffer(128);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java Wed Aug  8 19:56:38 2012
@@ -33,6 +33,7 @@ import java.io.InputStream;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.BufferInfo;
 import org.apache.http.io.SessionInputBuffer;
+import org.apache.http.util.Args;
 
 /**
  * Input stream that reads data without any transformation. The end of the
@@ -60,10 +61,7 @@ public class IdentityInputStream extends
      */
     public IdentityInputStream(final SessionInputBuffer in) {
         super();
-        if (in == null) {
-            throw new IllegalArgumentException("Session input buffer may not be null");
-        }
-        this.in = in;
+        this.in = Args.notNull(in, "Session input buffer");
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/IdentityOutputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/IdentityOutputStream.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/IdentityOutputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/IdentityOutputStream.java Wed Aug  8 19:56:38 2012
@@ -32,6 +32,7 @@ import java.io.OutputStream;
 
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.SessionOutputBuffer;
+import org.apache.http.util.Args;
 
 /**
  * Output stream that writes data without any transformation. The end of
@@ -58,10 +59,7 @@ public class IdentityOutputStream extend
 
     public IdentityOutputStream(final SessionOutputBuffer out) {
         super();
-        if (out == null) {
-            throw new IllegalArgumentException("Session output buffer may not be null");
-        }
-        this.out = out;
+        this.out = Args.notNull(out, "Session output buffer");
     }
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SocketInputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SocketInputBuffer.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SocketInputBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SocketInputBuffer.java Wed Aug  8 19:56:38 2012
@@ -35,6 +35,7 @@ import org.apache.http.annotation.NotThr
 import org.apache.http.io.EofSensor;
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 
 /**
  * {@link SessionInputBuffer} implementation bound to a {@link Socket}.
@@ -71,9 +72,7 @@ public class SocketInputBuffer extends A
             int buffersize,
             final HttpParams params) throws IOException {
         super();
-        if (socket == null) {
-            throw new IllegalArgumentException("Socket may not be null");
-        }
+        Args.notNull(socket, "Socket");
         this.socket = socket;
         this.eof = false;
         if (buffersize < 0) {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SocketOutputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SocketOutputBuffer.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SocketOutputBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SocketOutputBuffer.java Wed Aug  8 19:56:38 2012
@@ -33,6 +33,7 @@ import java.net.Socket;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.io.SessionOutputBuffer;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 
 /**
  * {@link SessionOutputBuffer} implementation bound to a {@link Socket}.
@@ -64,9 +65,7 @@ public class SocketOutputBuffer extends 
             int buffersize,
             final HttpParams params) throws IOException {
         super();
-        if (socket == null) {
-            throw new IllegalArgumentException("Socket may not be null");
-        }
+        Args.notNull(socket, "Socket");
         if (buffersize < 0) {
             buffersize = socket.getSendBufferSize();
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java Wed Aug  8 19:56:38 2012
@@ -39,6 +39,7 @@ import org.apache.http.impl.DefaultHttpC
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.pool.ConnFactory;
+import org.apache.http.util.Args;
 
 /**
  * A very basic {@link ConnFactory} implementation that creates
@@ -66,11 +67,8 @@ public class BasicConnFactory implements
 
     public BasicConnFactory(final SSLSocketFactory sslfactory, final HttpParams params) {
         super();
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP params may not be null");
-        }
         this.sslfactory = sslfactory;
-        this.params = params;
+        this.params = Args.notNull(params, "HTTP params");
     }
 
     public BasicConnFactory(final HttpParams params) {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/AbstractHttpMessage.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/AbstractHttpMessage.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/AbstractHttpMessage.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/AbstractHttpMessage.java Wed Aug  8 19:56:38 2012
@@ -33,6 +33,7 @@ import org.apache.http.HttpMessage;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
 
 /**
  * Basic implementation of {@link HttpMessage}.
@@ -88,9 +89,7 @@ public abstract class AbstractHttpMessag
 
     // non-javadoc, see interface HttpMessage
     public void addHeader(final String name, final String value) {
-        if (name == null) {
-            throw new IllegalArgumentException("Header name may not be null");
-        }
+        Args.notNull(name, "Header name");
         this.headergroup.addHeader(new BasicHeader(name, value));
     }
 
@@ -101,9 +100,7 @@ public abstract class AbstractHttpMessag
 
     // non-javadoc, see interface HttpMessage
     public void setHeader(final String name, final String value) {
-        if (name == null) {
-            throw new IllegalArgumentException("Header name may not be null");
-        }
+        Args.notNull(name, "Header name");
         this.headergroup.updateHeader(new BasicHeader(name, value));
     }
 
@@ -150,9 +147,6 @@ public abstract class AbstractHttpMessag
 
     // non-javadoc, see interface HttpMessage
     public void setParams(final HttpParams params) {
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
-        this.params = params;
+        this.params = Args.notNull(params, "HTTP parameters");
     }
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeader.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeader.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeader.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeader.java Wed Aug  8 19:56:38 2012
@@ -33,6 +33,7 @@ import org.apache.http.Header;
 import org.apache.http.HeaderElement;
 import org.apache.http.ParseException;
 import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
 
 /**
  * Basic implementation of {@link Header}.
@@ -55,10 +56,7 @@ public class BasicHeader implements Head
      */
     public BasicHeader(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/BasicHeaderElement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.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.NotThreadSafe;
+import org.apache.http.util.Args;
 import org.apache.http.util.LangUtils;
 
 /**
@@ -57,10 +58,7 @@ public class BasicHeaderElement implemen
             final String value,
             final NameValuePair[] parameters) {
         super();
-        if (name == null) {
-            throw new IllegalArgumentException("Name may not be null");
-        }
-        this.name = name;
+        this.name = Args.notNull(name, "Name");
         this.value = value;
         if (parameters != null) {
             this.parameters = parameters;
@@ -101,9 +99,7 @@ public class BasicHeaderElement implemen
     }
 
     public NameValuePair getParameterByName(final String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Name may not be null");
-        }
+        Args.notNull(name, "Name");
         NameValuePair found = null;
         for (int i = 0; i < this.parameters.length; i++) {
             NameValuePair current = this.parameters[ i ];

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java Wed Aug  8 19:56:38 2012
@@ -35,6 +35,7 @@ import org.apache.http.HeaderElement;
 import org.apache.http.HeaderElementIterator;
 import org.apache.http.HeaderIterator;
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -58,14 +59,8 @@ public class BasicHeaderElementIterator 
     public BasicHeaderElementIterator(
             final HeaderIterator headerIterator,
             final HeaderValueParser parser) {
-        if (headerIterator == null) {
-            throw new IllegalArgumentException("Header iterator may not be null");
-        }
-        if (parser == null) {
-            throw new IllegalArgumentException("Parser may not be null");
-        }
-        this.headerIt = headerIterator;
-        this.parser = parser;
+        this.headerIt = Args.notNull(headerIterator, "Header iterator");
+        this.parser = Args.notNull(parser, "Parser");
     }
 
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderIterator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderIterator.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderIterator.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/message/BasicHeaderIterator.java Wed Aug  8 19:56:38 2012
@@ -32,6 +32,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;
 
 /**
  * Basic implementation of a {@link HeaderIterator}.
@@ -73,12 +74,8 @@ public class BasicHeaderIterator impleme
      *                  <code>null</code> for any
      */
     public BasicHeaderIterator(Header[] headers, String name) {
-        if (headers == null) {
-            throw new IllegalArgumentException
-                ("Header array must not be null.");
-        }
-
-        this.allHeaders = headers;
+        super();
+        this.allHeaders = Args.notNull(headers, "Header array");
         this.headerName = name;
         this.currentIndex = findNext(-1);
     }



Mime
View raw message