You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2012/08/08 21:56:44 UTC
svn commit: r1370923 [2/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/...
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnFactory.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnFactory.java Wed Aug 8 19:56:38 2012
@@ -45,6 +45,7 @@ import org.apache.http.nio.reactor.ssl.S
import org.apache.http.nio.util.ByteBufferAllocator;
import org.apache.http.nio.util.HeapByteBufferAllocator;
import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
/**
* A basic {@link NIOConnFactory} implementation that creates
@@ -71,9 +72,7 @@ public class BasicNIOConnFactory impleme
final NHttpConnectionFactory<? extends NHttpClientConnection> plainFactory,
final NHttpConnectionFactory<? extends NHttpClientConnection> sslFactory) {
super();
- if (plainFactory == null) {
- throw new IllegalArgumentException("Plain HTTP client connection factory may not be null");
- }
+ Args.notNull(plainFactory, "Plain HTTP client connection factory");
this.plainFactory = plainFactory;
this.sslFactory = sslFactory;
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java Wed Aug 8 19:56:38 2012
@@ -42,6 +42,7 @@ import org.apache.http.nio.reactor.Conne
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.pool.ConnPool;
+import org.apache.http.util.Args;
/**
* A very basic {@link ConnPool} implementation that represents a pool
@@ -76,9 +77,7 @@ public class BasicNIOConnPool extends Ab
final NIOConnFactory<HttpHost, NHttpClientConnection> connFactory,
final HttpParams params) {
super(ioreactor, connFactory, 2, 20);
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(params, "HTTP parameters");
this.params = params;
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java Wed Aug 8 19:56:38 2012
@@ -47,6 +47,7 @@ import org.apache.http.nio.reactor.IORea
import org.apache.http.nio.reactor.IOReactorException;
import org.apache.http.nio.reactor.IOReactorStatus;
import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.util.Args;
/**
* Generic implementation of {@link IOReactor} that can used as a subclass
@@ -91,9 +92,7 @@ public abstract class AbstractIOReactor
*/
public AbstractIOReactor(long selectTimeout, boolean interestOpsQueueing) throws IOReactorException {
super();
- if (selectTimeout <= 0) {
- throw new IllegalArgumentException("Select timeout may not be negative or zero");
- }
+ Args.positive(selectTimeout, "Select timeout");
this.selectTimeout = selectTimeout;
this.interestOpsQueueing = interestOpsQueueing;
this.sessions = Collections.synchronizedSet(new HashSet<IOSession>());
@@ -219,9 +218,7 @@ public abstract class AbstractIOReactor
* @param channelEntry the channel entry.
*/
public void addChannel(final ChannelEntry channelEntry) {
- if (channelEntry == null) {
- throw new IllegalArgumentException("Channel entry may not be null");
- }
+ Args.notNull(channelEntry, "Channel entry");
this.newChannels.add(channelEntry);
this.selector.wakeup();
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java Wed Aug 8 19:56:38 2012
@@ -53,6 +53,7 @@ import org.apache.http.nio.reactor.IORea
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
/**
* Generic implementation of {@link IOReactor} that can run multiple
@@ -189,9 +190,7 @@ public abstract class AbstractMultiworke
}
static IOReactorConfig convert(int workerCount, final HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(params, "HTTP parameters");
IOReactorConfig config = new IOReactorConfig();
config.setSelectInterval(NIOReactorParams.getSelectInterval(params));
config.setShutdownGracePeriod(NIOReactorParams.getGracePeriod(params));
@@ -326,9 +325,7 @@ public abstract class AbstractMultiworke
*/
public void execute(
final IOEventDispatch eventDispatch) throws InterruptedIOException, IOReactorException {
- if (eventDispatch == null) {
- throw new IllegalArgumentException("Event dispatcher may not be null");
- }
+ Args.notNull(eventDispatch, "Event dispatcher");
synchronized (this.statusLock) {
if (this.status.compareTo(IOReactorStatus.SHUTDOWN_REQUEST) >= 0) {
this.status = IOReactorStatus.SHUT_DOWN;
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java Wed Aug 8 19:56:38 2012
@@ -41,6 +41,7 @@ import org.apache.http.nio.reactor.IORea
import org.apache.http.nio.reactor.IOReactorException;
import org.apache.http.nio.reactor.IOReactorExceptionHandler;
import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.util.Args;
/**
* Default implementation of {@link AbstractIOReactor} that serves as a base
@@ -99,9 +100,7 @@ public class BaseIOReactor extends Abstr
*/
public void execute(
final IOEventDispatch eventDispatch) throws InterruptedIOException, IOReactorException {
- if (eventDispatch == null) {
- throw new IllegalArgumentException("Event dispatcher may not be null");
- }
+ Args.notNull(eventDispatch, "Event dispatcher");
this.eventDispatch = eventDispatch;
execute();
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ChannelEntry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ChannelEntry.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ChannelEntry.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ChannelEntry.java Wed Aug 8 19:56:38 2012
@@ -30,6 +30,7 @@ package org.apache.http.impl.nio.reactor
import java.nio.channels.SocketChannel;
import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
/**
* {@link SocketChannel} entry maintained by the I/O reactor. If the channel
@@ -53,9 +54,7 @@ public class ChannelEntry {
*/
public ChannelEntry(final SocketChannel channel, final SessionRequestImpl sessionRequest) {
super();
- if (channel == null) {
- throw new IllegalArgumentException("Socket channel may not be null");
- }
+ Args.notNull(channel, "Socket channel");
this.channel = channel;
this.sessionRequest = sessionRequest;
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java Wed Aug 8 19:56:38 2012
@@ -31,6 +31,7 @@ import java.net.SocketOptions;
import java.nio.channels.SelectionKey;
import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.util.Args;
/**
* I/O reactor configuration parameters.
@@ -82,9 +83,7 @@ public final class IOReactorConfig imple
* timed out sessions and session requests. May not be negative or zero.
*/
public void setSelectInterval(long selectInterval) {
- if (selectInterval <= 0) {
- throw new IllegalArgumentException("Select internal may not be negative or zero");
- }
+ Args.positive(selectInterval, "Select internal");
this.selectInterval = selectInterval;
}
@@ -103,9 +102,7 @@ public final class IOReactorConfig imple
* for individual worker threads to terminate cleanly. May not be negative or zero.
*/
public void setShutdownGracePeriod(long gracePeriod) {
- if (gracePeriod <= 0) {
- throw new IllegalArgumentException("Shutdown grace period may not be negative or zero");
- }
+ Args.positive(gracePeriod, "Shutdown grace period");
this.shutdownGracePeriod = gracePeriod;
}
@@ -151,9 +148,7 @@ public final class IOReactorConfig imple
* May not be negative or zero.
*/
public void setIoThreadCount(int ioThreadCount) {
- if (ioThreadCount <= 0) {
- throw new IllegalArgumentException("I/O thread count may not be negative or zero");
- }
+ Args.positive(ioThreadCount, "I/O thread count");
this.ioThreadCount = ioThreadCount;
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java Wed Aug 8 19:56:38 2012
@@ -43,6 +43,7 @@ import org.apache.http.annotation.Thread
import org.apache.http.nio.reactor.IOSession;
import org.apache.http.nio.reactor.SessionBufferStatus;
import org.apache.http.nio.reactor.SocketAccessor;
+import org.apache.http.util.Args;
/**
* Default implementation of {@link IOSession}.
@@ -83,9 +84,7 @@ public class IOSessionImpl implements IO
final InterestOpsCallback interestOpsCallback,
final SessionClosedCallback sessionClosedCallback) {
super();
- if (key == null) {
- throw new IllegalArgumentException("Selection key may not be null");
- }
+ Args.notNull(key, "Selection key");
this.key = key;
this.channel = (ByteChannel) this.key.channel();
this.interestOpsCallback = interestOpsCallback;
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/InterestOpEntry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/InterestOpEntry.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/InterestOpEntry.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/InterestOpEntry.java Wed Aug 8 19:56:38 2012
@@ -29,6 +29,8 @@ package org.apache.http.impl.nio.reactor
import java.nio.channels.SelectionKey;
+import org.apache.http.util.Args;
+
/**
* Helper class, representing an entry on an {@link java.nio.channels.SelectionKey#interestOps(int)
* interestOps(int)} queue.
@@ -42,9 +44,7 @@ class InterestOpEntry {
public InterestOpEntry(final SelectionKey key, int eventMask) {
super();
- if (key == null) {
- throw new IllegalArgumentException("Selection key may not be null");
- }
+ Args.notNull(key, "Selection key");
this.key = key;
this.eventMask = eventMask;
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointImpl.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointImpl.java Wed Aug 8 19:56:38 2012
@@ -34,6 +34,7 @@ import java.nio.channels.SelectionKey;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.nio.reactor.ListenerEndpoint;
+import org.apache.http.util.Args;
/**
* Default implementation of {@link ListenerEndpoint}.
@@ -55,9 +56,7 @@ public class ListenerEndpointImpl implem
final SocketAddress address,
final ListenerEndpointClosedCallback callback) {
super();
- if (address == null) {
- throw new IllegalArgumentException("Address may not be null");
- }
+ Args.notNull(address, "Address");
this.address = address;
this.callback = callback;
}
@@ -86,9 +85,7 @@ public class ListenerEndpointImpl implem
}
public void completed(final SocketAddress address) {
- if (address == null) {
- throw new IllegalArgumentException("Address may not be null");
- }
+ Args.notNull(address, "Address");
if (this.completed) {
return;
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java Wed Aug 8 19:56:38 2012
@@ -28,6 +28,7 @@
package org.apache.http.impl.nio.reactor;
import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.util.Args;
/**
* Session handle class used by I/O reactor implementations to keep a reference
@@ -50,9 +51,7 @@ public class SessionHandle {
public SessionHandle(final IOSession session) {
super();
- if (session == null) {
- throw new IllegalArgumentException("Session may not be null");
- }
+ Args.notNull(session, "Session");
this.session = session;
long now = System.currentTimeMillis();
this.startedTime = now;
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java Wed Aug 8 19:56:38 2012
@@ -45,6 +45,7 @@ import org.apache.http.nio.util.HeapByte
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.CharArrayBuffer;
/**
@@ -87,9 +88,7 @@ public class SessionInputBufferImpl exte
}
public int fill(final ReadableByteChannel channel) throws IOException {
- if (channel == null) {
- throw new IllegalArgumentException("Channel may not be null");
- }
+ Args.notNull(channel, "Channel");
setInputMode();
if (!this.buffer.hasRemaining()) {
expand();
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java Wed Aug 8 19:56:38 2012
@@ -45,6 +45,7 @@ import org.apache.http.nio.util.HeapByte
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.CharArrayBuffer;
/**
@@ -93,9 +94,7 @@ public class SessionOutputBufferImpl ext
}
public int flush(final WritableByteChannel channel) throws IOException {
- if (channel == null) {
- throw new IllegalArgumentException("Channel may not be null");
- }
+ Args.notNull(channel, "Channel");
setOutputMode();
int noWritten = channel.write(this.buffer);
return noWritten;
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestHandle.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestHandle.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestHandle.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestHandle.java Wed Aug 8 19:56:38 2012
@@ -29,6 +29,7 @@ package org.apache.http.impl.nio.reactor
import org.apache.http.annotation.Immutable;
import org.apache.http.nio.reactor.SessionRequest;
+import org.apache.http.util.Args;
/**
* Session request handle class used by I/O reactor implementations to keep
@@ -45,9 +46,7 @@ public class SessionRequestHandle {
public SessionRequestHandle(final SessionRequestImpl sessionRequest) {
super();
- if (sessionRequest == null) {
- throw new IllegalArgumentException("Session request may not be null");
- }
+ Args.notNull(sessionRequest, "Session request");
this.sessionRequest = sessionRequest;
this.requestTime = System.currentTimeMillis();
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestImpl.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestImpl.java Wed Aug 8 19:56:38 2012
@@ -36,6 +36,7 @@ import org.apache.http.annotation.Thread
import org.apache.http.nio.reactor.IOSession;
import org.apache.http.nio.reactor.SessionRequest;
import org.apache.http.nio.reactor.SessionRequestCallback;
+import org.apache.http.util.Args;
/**
* Default implementation of {@link SessionRequest}.
@@ -63,9 +64,7 @@ public class SessionRequestImpl implemen
final Object attachment,
final SessionRequestCallback callback) {
super();
- if (remoteAddress == null) {
- throw new IllegalArgumentException("Remote address may not be null");
- }
+ Args.notNull(remoteAddress, "Remote address");
this.remoteAddress = remoteAddress;
this.localAddress = localAddress;
this.attachment = attachment;
@@ -117,9 +116,7 @@ public class SessionRequestImpl implemen
}
public void completed(final IOSession session) {
- if (session == null) {
- throw new IllegalArgumentException("Session may not be null");
- }
+ Args.notNull(session, "Session");
if (this.completed) {
return;
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java Wed Aug 8 19:56:38 2012
@@ -31,8 +31,8 @@ import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLException;
import org.apache.http.annotation.Immutable;
-import org.apache.http.impl.nio.DefaultHttpClientIODispatch;
import org.apache.http.impl.nio.DefaultClientIOEventDispatch;
+import org.apache.http.impl.nio.DefaultHttpClientIODispatch;
import org.apache.http.impl.nio.reactor.SSLIOSession;
import org.apache.http.impl.nio.reactor.SSLSetupHandler;
import org.apache.http.nio.NHttpClientHandler;
@@ -41,6 +41,7 @@ import org.apache.http.nio.reactor.IOEve
import org.apache.http.nio.reactor.IOSession;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
/**
* Default implementation of {@link IOEventDispatch} interface for SSL
@@ -84,12 +85,8 @@ public class SSLClientIOEventDispatch ex
final SSLSetupHandler sslHandler,
final HttpParams params) {
super(handler, params);
- if (sslcontext == null) {
- throw new IllegalArgumentException("SSL context may not be null");
- }
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(sslcontext, "SSL context");
+ Args.notNull(params, "HTTP parameters");
this.sslcontext = sslcontext;
this.sslHandler = sslHandler;
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java Wed Aug 8 19:56:38 2012
@@ -41,6 +41,7 @@ import org.apache.http.nio.reactor.IOEve
import org.apache.http.nio.reactor.IOSession;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
/**
* Default implementation of {@link IOEventDispatch} interface for SSL
@@ -84,12 +85,8 @@ public class SSLServerIOEventDispatch ex
final SSLSetupHandler sslHandler,
final HttpParams params) {
super(handler, params);
- if (sslcontext == null) {
- throw new IllegalArgumentException("SSL context may not be null");
- }
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(sslcontext, "SSL context");
+ Args.notNull(params, "HTTP parameters");
this.sslcontext = sslcontext;
this.sslHandler = sslHandler;
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/ContentEncoderChannel.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/ContentEncoderChannel.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/ContentEncoderChannel.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/ContentEncoderChannel.java Wed Aug 8 19:56:38 2012
@@ -31,8 +31,6 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.WritableByteChannel;
-import org.apache.http.nio.ContentEncoder;
-
/**
* A {@link WritableByteChannel} that delegates to a {@link ContentEncoder}.
* Attempts to close this channel are ignored, and {@link #isOpen} always
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/FileContentEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/FileContentEncoder.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/FileContentEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/FileContentEncoder.java Wed Aug 8 19:56:38 2012
@@ -29,7 +29,6 @@ package org.apache.http.nio;
import java.io.IOException;
import java.nio.channels.FileChannel;
-import org.apache.http.nio.ContentEncoder;
/**
* A content encoder capable of transferring data directly from a {@link FileChannel}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/BufferingNHttpEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/BufferingNHttpEntity.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/BufferingNHttpEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/BufferingNHttpEntity.java Wed Aug 8 19:56:38 2012
@@ -40,6 +40,7 @@ import org.apache.http.nio.protocol.Basi
import org.apache.http.nio.protocol.BasicAsyncResponseConsumer;
import org.apache.http.nio.util.ByteBufferAllocator;
import org.apache.http.nio.util.SimpleInputBuffer;
+import org.apache.http.util.Args;
/**
* A {@link ConsumingNHttpEntity} that consumes content into a buffer. The
@@ -116,9 +117,7 @@ public class BufferingNHttpEntity extend
@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");
InputStream instream = getContent();
byte[] buffer = new byte[BUFFER_SIZE];
int l;
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentBufferEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentBufferEntity.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentBufferEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentBufferEntity.java Wed Aug 8 19:56:38 2012
@@ -32,6 +32,7 @@ import org.apache.http.HttpEntity;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.entity.BasicHttpEntity;
import org.apache.http.nio.util.ContentInputBuffer;
+import org.apache.http.util.Args;
/**
* HTTP entity wrapper whose content is provided by a
@@ -52,9 +53,7 @@ public class ContentBufferEntity extends
*/
public ContentBufferEntity(final HttpEntity entity, final ContentInputBuffer buffer) {
super();
- if (entity == null) {
- throw new IllegalArgumentException("HTTP entity may not be null");
- }
+ Args.notNull(entity, "HTTP entity");
this.wrappedEntity = entity;
setContent(new ContentInputStream(buffer));
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.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.nio.util.ContentInputBuffer;
+import org.apache.http.util.Args;
/**
* {@link InputStream} adaptor for {@link ContentInputBuffer}.
@@ -46,9 +47,7 @@ public class ContentInputStream extends
public ContentInputStream(final ContentInputBuffer buffer) {
super();
- if (buffer == null) {
- throw new IllegalArgumentException("Input buffer may not be null");
- }
+ Args.notNull(buffer, "Input buffer");
this.buffer = buffer;
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.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.nio.util.ContentOutputBuffer;
+import org.apache.http.util.Args;
/**
* {@link OutputStream} adaptor for {@link ContentOutputBuffer}.
@@ -45,9 +46,7 @@ public class ContentOutputStream extends
public ContentOutputStream(final ContentOutputBuffer buffer) {
super();
- if (buffer == null) {
- throw new IllegalArgumentException("Output buffer may not be null");
- }
+ Args.notNull(buffer, "Output buffer");
this.buffer = buffer;
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/EntityAsyncContentProducer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/EntityAsyncContentProducer.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/EntityAsyncContentProducer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/EntityAsyncContentProducer.java Wed Aug 8 19:56:38 2012
@@ -36,6 +36,7 @@ import org.apache.http.HttpEntity;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.nio.ContentEncoder;
import org.apache.http.nio.IOControl;
+import org.apache.http.util.Args;
/**
* Basic implementation of {@link HttpAsyncContentProducer} that relies on
@@ -53,9 +54,7 @@ public class EntityAsyncContentProducer
public EntityAsyncContentProducer(final HttpEntity entity) {
super();
- if (entity == null) {
- throw new IllegalArgumentException("HTTP entity may not be null");
- }
+ Args.notNull(entity, "HTTP entity");
this.entity = entity;
this.buffer = ByteBuffer.allocate(4096);
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java Wed Aug 8 19:56:38 2012
@@ -38,6 +38,7 @@ import org.apache.http.entity.AbstractHt
import org.apache.http.entity.ContentType;
import org.apache.http.nio.ContentEncoder;
import org.apache.http.nio.IOControl;
+import org.apache.http.util.Args;
/**
* A simple self contained, repeatable non-blocking entity that retrieves
@@ -69,9 +70,7 @@ public class NByteArrayEntity extends Ab
*/
public NByteArrayEntity(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.b = b;
this.off = 0;
this.len = b.length;
@@ -88,9 +87,7 @@ public class NByteArrayEntity extends Ab
*/
public NByteArrayEntity(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);
@@ -157,9 +154,7 @@ public class NByteArrayEntity extends Ab
}
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-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java Wed Aug 8 19:56:38 2012
@@ -41,6 +41,7 @@ import org.apache.http.nio.ContentEncode
import org.apache.http.nio.ContentEncoderChannel;
import org.apache.http.nio.FileContentEncoder;
import org.apache.http.nio.IOControl;
+import org.apache.http.util.Args;
/**
* A self contained, repeatable non-blocking entity that retrieves its content
@@ -74,9 +75,7 @@ public class NFileEntity extends Abstrac
* @since 4.2
*/
public NFileEntity(final File file, final ContentType contentType, boolean useFileChannels) {
- if (file == null) {
- throw new IllegalArgumentException("File may not be null");
- }
+ Args.notNull(file, "File");
this.file = file;
this.useFileChannels = useFileChannels;
if (contentType != null) {
@@ -88,9 +87,7 @@ public class NFileEntity extends Abstrac
* @since 4.2
*/
public NFileEntity(final File file) {
- if (file == null) {
- throw new IllegalArgumentException("File may not be null");
- }
+ Args.notNull(file, "File");
this.file = file;
}
/**
@@ -111,9 +108,7 @@ public class NFileEntity extends Abstrac
*/
@Deprecated
public NFileEntity(final File file, final String contentType, boolean useFileChannels) {
- if (file == null) {
- throw new IllegalArgumentException("File may not be null");
- }
+ Args.notNull(file, "File");
this.file = file;
this.useFileChannels = useFileChannels;
setContentType(contentType);
@@ -191,9 +186,7 @@ public class NFileEntity extends Abstrac
}
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-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java Wed Aug 8 19:56:38 2012
@@ -42,6 +42,7 @@ import org.apache.http.entity.ContentTyp
import org.apache.http.nio.ContentEncoder;
import org.apache.http.nio.IOControl;
import org.apache.http.protocol.HTTP;
+import org.apache.http.util.Args;
/**
* A simple, self contained, repeatable non-blocking entity that retrieves
@@ -80,9 +81,7 @@ public class NStringEntity extends Abstr
* @since 4.2
*/
public NStringEntity(final String s, final ContentType contentType) {
- if (s == null) {
- throw new IllegalArgumentException("Source string may not be null");
- }
+ Args.notNull(s, "Source string");
Charset charset = contentType != null ? contentType.getCharset() : null;
if (charset == null) {
charset = HTTP.DEF_CONTENT_CHARSET;
@@ -189,9 +188,7 @@ public class NStringEntity extends Abstr
}
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);
outstream.flush();
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/SkipContentListener.java Wed Aug 8 19:56:38 2012
@@ -33,6 +33,7 @@ import java.nio.ByteBuffer;
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.IOControl;
import org.apache.http.nio.util.ByteBufferAllocator;
+import org.apache.http.util.Args;
/**
* A simple {@link ContentListener} that reads and ignores all content.
@@ -48,9 +49,7 @@ public class SkipContentListener impleme
public SkipContentListener(final ByteBufferAllocator allocator) {
super();
- if (allocator == null) {
- throw new IllegalArgumentException("ByteBuffer allocator may not be null");
- }
+ Args.notNull(allocator, "ByteBuffer allocator");
this.buffer = allocator.allocate(2048);
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorParams.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorParams.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorParams.java Wed Aug 8 19:56:38 2012
@@ -29,6 +29,7 @@ package org.apache.http.nio.params;
import org.apache.http.impl.nio.reactor.IOReactorConfig;
import org.apache.http.params.HttpParams;
+import org.apache.http.util.Args;
/**
* Utility class for accessing I/O reactor parameters in {@link HttpParams}.
@@ -54,9 +55,7 @@ public final class NIOReactorParams impl
* @return content buffer size.
*/
public static int getContentBufferSize(final HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(params, "HTTP parameters");
return params.getIntParameter(CONTENT_BUFFER_SIZE, 4096);
}
@@ -67,9 +66,7 @@ public final class NIOReactorParams impl
* @param size content buffer size.
*/
public static void setContentBufferSize(final HttpParams params, int size) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(params, "HTTP parameters");
params.setIntParameter(CONTENT_BUFFER_SIZE, size);
}
@@ -81,9 +78,7 @@ public final class NIOReactorParams impl
* @return I/O select interval in milliseconds.
*/
public static long getSelectInterval(final HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(params, "HTTP parameters");
return params.getLongParameter(SELECT_INTERVAL, 1000);
}
@@ -94,9 +89,7 @@ public final class NIOReactorParams impl
* @param ms I/O select interval in milliseconds.
*/
public static void setSelectInterval(final HttpParams params, long ms) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(params, "HTTP parameters");
params.setLongParameter(SELECT_INTERVAL, ms);
}
@@ -108,9 +101,7 @@ public final class NIOReactorParams impl
* @return shutdown grace period in milliseconds.
*/
public static long getGracePeriod(final HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(params, "HTTP parameters");
return params.getLongParameter(GRACE_PERIOD, 500);
}
@@ -121,9 +112,7 @@ public final class NIOReactorParams impl
* @param ms shutdown grace period in milliseconds.
*/
public static void setGracePeriod(final HttpParams params, long ms) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(params, "HTTP parameters");
params.setLongParameter(GRACE_PERIOD, ms);
}
@@ -137,9 +126,7 @@ public final class NIOReactorParams impl
* @since 4.1
*/
public static boolean getInterestOpsQueueing(final HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(params, "HTTP parameters");
return params.getBooleanParameter(INTEREST_OPS_QUEUEING, false);
}
@@ -153,9 +140,7 @@ public final class NIOReactorParams impl
*/
public static void setInterestOpsQueueing(
final HttpParams params, boolean interestOpsQueueing) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(params, "HTTP parameters");
params.setBooleanParameter(INTEREST_OPS_QUEUEING, interestOpsQueueing);
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java Wed Aug 8 19:56:38 2012
@@ -52,6 +52,7 @@ import org.apache.http.pool.ConnPool;
import org.apache.http.pool.ConnPoolControl;
import org.apache.http.pool.PoolEntry;
import org.apache.http.pool.PoolStats;
+import org.apache.http.util.Args;
/**
* Abstract non-blocking connection pool.
@@ -87,18 +88,10 @@ public abstract class AbstractNIOConnPoo
int defaultMaxPerRoute,
int maxTotal) {
super();
- if (ioreactor == null) {
- throw new IllegalArgumentException("I/O reactor may not be null");
- }
- 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");
- }
+ Args.notNull(ioreactor, "I/O reactor");
+ Args.notNull(connFactory, "Connection factory");
+ Args.positive(defaultMaxPerRoute, "Max per route value");
+ Args.positive(maxTotal, "Max total value");
this.ioreactor = ioreactor;
this.connFactory = connFactory;
this.sessionRequestCallback = new InternalSessionRequestCallback();
@@ -173,12 +166,8 @@ public abstract class AbstractNIOConnPoo
final T route, final Object state,
final long connectTimeout, final TimeUnit tunit,
final FutureCallback<E> callback) {
- if (route == null) {
- throw new IllegalArgumentException("Route may not be null");
- }
- if (tunit == null) {
- throw new IllegalArgumentException("Time unit may not be null.");
- }
+ Args.notNull(route, "Route");
+ Args.notNull(tunit, "Time unit");
if (this.isShutDown) {
throw new IllegalStateException("Session pool has been shut down");
}
@@ -417,9 +406,7 @@ public abstract class AbstractNIOConnPoo
}
public void setMaxTotal(int max) {
- if (max <= 0) {
- throw new IllegalArgumentException("Max value may not be negative or zero");
- }
+ Args.positive(max, "Max value");
this.lock.lock();
try {
this.maxTotal = max;
@@ -438,9 +425,7 @@ public abstract class AbstractNIOConnPoo
}
public void setDefaultMaxPerRoute(int max) {
- if (max <= 0) {
- throw new IllegalArgumentException("Max value may not be negative or zero");
- }
+ Args.positive(max, "Max value");
this.lock.lock();
try {
this.defaultMaxPerRoute = max;
@@ -459,12 +444,8 @@ public abstract class AbstractNIOConnPoo
}
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.positive(max, "Max value");
this.lock.lock();
try {
this.maxPerRoute.put(route, max);
@@ -474,9 +455,7 @@ public abstract class AbstractNIOConnPoo
}
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);
@@ -499,9 +478,7 @@ public abstract class AbstractNIOConnPoo
}
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);
@@ -516,9 +493,7 @@ public abstract class AbstractNIOConnPoo
}
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-nio/src/main/java/org/apache/http/nio/pool/RouteSpecificPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/RouteSpecificPool.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/RouteSpecificPool.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/RouteSpecificPool.java Wed Aug 8 19:56:38 2012
@@ -38,6 +38,7 @@ import org.apache.http.annotation.NotThr
import org.apache.http.concurrent.BasicFuture;
import org.apache.http.nio.reactor.SessionRequest;
import org.apache.http.pool.PoolEntry;
+import org.apache.http.util.Args;
@NotThreadSafe
abstract class RouteSpecificPool<T, C, E extends PoolEntry<T, C>> {
@@ -108,9 +109,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;
@@ -120,9 +119,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-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpClientHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpClientHandler.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpClientHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpClientHandler.java Wed Aug 8 19:56:38 2012
@@ -52,6 +52,7 @@ import org.apache.http.params.HttpParams
import org.apache.http.protocol.ExecutionContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.util.Args;
/**
* Fully asynchronous HTTP client side protocol handler that implements the
@@ -103,10 +104,7 @@ public class AsyncNHttpClientHandler ext
final ByteBufferAllocator allocator,
final HttpParams params) {
super(httpProcessor, connStrategy, allocator, params);
- if (execHandler == null) {
- throw new IllegalArgumentException("HTTP request execution handler may not be null.");
- }
- this.execHandler = execHandler;
+ this.execHandler = Args.notNull(execHandler, "HTTP request execution handler");
}
public AsyncNHttpClientHandler(
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java Wed Aug 8 19:56:38 2012
@@ -60,6 +60,7 @@ import org.apache.http.protocol.Executio
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpExpectationVerifier;
import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.util.Args;
import org.apache.http.util.EncodingUtils;
/**
@@ -114,9 +115,7 @@ public class AsyncNHttpServiceHandler ex
final ByteBufferAllocator allocator,
final HttpParams params) {
super(httpProcessor, connStrategy, allocator, params);
- if (responseFactory == null) {
- throw new IllegalArgumentException("Response factory may not be null");
- }
+ Args.notNull(responseFactory, "Response factory");
this.responseFactory = responseFactory;
}
@@ -658,9 +657,7 @@ public class AsyncNHttpServiceHandler ex
}
public void submitResponse(final HttpResponse response) {
- if (response == null) {
- throw new IllegalArgumentException("Response may not be null");
- }
+ Args.notNull(response, "Response");
if (this.triggered) {
throw new IllegalStateException("Response already triggered");
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestExecutionHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestExecutionHandler.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestExecutionHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestExecutionHandler.java Wed Aug 8 19:56:38 2012
@@ -44,6 +44,7 @@ import org.apache.http.params.DefaultedH
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.util.Args;
/**
* Basic implementation of {@link HttpAsyncRequestExecutionHandler} that executes
@@ -73,24 +74,12 @@ public class BasicAsyncRequestExecutionH
final ConnectionReuseStrategy reuseStrategy,
final HttpParams params) {
super();
- if (requestProducer == null) {
- throw new IllegalArgumentException("Request producer may not be null");
- }
- if (responseConsumer == null) {
- throw new IllegalArgumentException("Response consumer may not be null");
- }
- if (localContext == null) {
- throw new IllegalArgumentException("HTTP context may not be null");
- }
- if (httppocessor == null) {
- throw new IllegalArgumentException("HTTP processor may not be null");
- }
- if (reuseStrategy == null) {
- throw new IllegalArgumentException("Connection reuse strategy may not be null");
- }
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(requestProducer, "Request producer");
+ Args.notNull(responseConsumer, "Response consumer");
+ Args.notNull(localContext, "HTTP context");
+ Args.notNull(httppocessor, "HTTP processor");
+ Args.notNull(reuseStrategy, "Connection reuse strategy");
+ Args.notNull(params, "HTTP parameters");
this.requestProducer = requestProducer;
this.responseConsumer = responseConsumer;
this.future = new BasicFuture<T>(callback);
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestHandler.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestHandler.java Wed Aug 8 19:56:38 2012
@@ -34,6 +34,7 @@ import org.apache.http.HttpRequest;
import org.apache.http.annotation.Immutable;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpRequestHandler;
+import org.apache.http.util.Args;
/**
* Basic implementation of {@link HttpAsyncRequestHandler} that delegates
@@ -50,9 +51,7 @@ public class BasicAsyncRequestHandler im
public BasicAsyncRequestHandler(final HttpRequestHandler handler) {
super();
- if (handler == null) {
- throw new IllegalArgumentException("Request handler may not be null");
- }
+ Args.notNull(handler, "Request handler");
this.handler = handler;
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestProducer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestProducer.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestProducer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestProducer.java Wed Aug 8 19:56:38 2012
@@ -38,6 +38,7 @@ import org.apache.http.nio.IOControl;
import org.apache.http.nio.entity.EntityAsyncContentProducer;
import org.apache.http.nio.entity.HttpAsyncContentProducer;
import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
/**
* Basic implementation of {@link HttpAsyncRequestProducer}. The producer
@@ -72,15 +73,9 @@ public class BasicAsyncRequestProducer i
final HttpEntityEnclosingRequest request,
final HttpAsyncContentProducer producer) {
super();
- if (target == null) {
- throw new IllegalArgumentException("HTTP host may not be null");
- }
- if (request == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
- if (producer == null) {
- throw new IllegalArgumentException("HTTP content producer may not be null");
- }
+ Args.notNull(target, "HTTP host");
+ Args.notNull(request, "HTTP request");
+ Args.notNull(producer, "HTTP content producer");
this.target = target;
this.request = request;
this.producer = producer;
@@ -95,12 +90,8 @@ public class BasicAsyncRequestProducer i
* @param request request message.
*/
public BasicAsyncRequestProducer(final HttpHost target, final HttpRequest request) {
- if (target == null) {
- throw new IllegalArgumentException("HTTP host may not be null");
- }
- if (request == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
+ Args.notNull(target, "HTTP host");
+ Args.notNull(request, "HTTP request");
this.target = target;
this.request = request;
if (request instanceof HttpEntityEnclosingRequest) {
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseProducer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseProducer.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseProducer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseProducer.java Wed Aug 8 19:56:38 2012
@@ -37,6 +37,7 @@ import org.apache.http.nio.IOControl;
import org.apache.http.nio.entity.EntityAsyncContentProducer;
import org.apache.http.nio.entity.HttpAsyncContentProducer;
import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.Args;
/**
* Basic implementation of {@link HttpAsyncResponseProducer}. The producer
@@ -69,12 +70,8 @@ public class BasicAsyncResponseProducer
final HttpResponse response,
final HttpAsyncContentProducer producer) {
super();
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
- if (producer == null) {
- throw new IllegalArgumentException("HTTP content producer may not be null");
- }
+ Args.notNull(response, "HTTP response");
+ Args.notNull(producer, "HTTP content producer");
this.response = response;
this.producer = producer;
}
@@ -88,9 +85,7 @@ public class BasicAsyncResponseProducer
*/
public BasicAsyncResponseProducer(final HttpResponse response) {
super();
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
+ Args.notNull(response, "HTTP response");
this.response = response;
HttpEntity entity = response.getEntity();
if (entity != null) {
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequester.java Wed Aug 8 19:56:38 2012
@@ -44,6 +44,7 @@ import org.apache.http.pool.PoolEntry;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.util.Args;
/**
* <tt>HttpAsyncRequester</tt> is a utility class that can be used
@@ -88,18 +89,10 @@ public class HttpAsyncRequester {
final NHttpClientConnection conn,
final HttpContext context,
final FutureCallback<T> callback) {
- if (requestProducer == null) {
- throw new IllegalArgumentException("HTTP request producer may not be null");
- }
- if (responseConsumer == null) {
- throw new IllegalArgumentException("HTTP response consumer 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");
- }
+ Args.notNull(requestProducer, "HTTP request producer");
+ Args.notNull(responseConsumer, "HTTP response consumer");
+ Args.notNull(conn, "HTTP connection");
+ Args.notNull(context, "HTTP context");
BasicAsyncRequestExecutionHandler<T> handler = new BasicAsyncRequestExecutionHandler<T>(
requestProducer, responseConsumer, callback, context,
this.httppocessor, this.reuseStrategy, this.params);
@@ -173,18 +166,10 @@ public class HttpAsyncRequester {
final ConnPool<HttpHost, E> connPool,
final HttpContext context,
final FutureCallback<T> callback) {
- if (requestProducer == null) {
- throw new IllegalArgumentException("HTTP request producer may not be null");
- }
- if (responseConsumer == null) {
- throw new IllegalArgumentException("HTTP response consumer may not be null");
- }
- if (connPool == null) {
- throw new IllegalArgumentException("HTTP connection pool may not be null");
- }
- if (context == null) {
- throw new IllegalArgumentException("HTTP context may not be null");
- }
+ Args.notNull(requestProducer, "HTTP request producer");
+ Args.notNull(responseConsumer, "HTTP response consumer");
+ Args.notNull(connPool, "HTTP connection pool");
+ Args.notNull(context, "HTTP context");
BasicFuture<T> future = new BasicFuture<T>(callback);
HttpHost target = requestProducer.getTarget();
connPool.lease(target, null, new ConnRequestCallback<T, E>(
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java Wed Aug 8 19:56:38 2012
@@ -61,6 +61,7 @@ import org.apache.http.protocol.BasicHtt
import org.apache.http.protocol.ExecutionContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.util.Args;
/**
* <tt>HttpAsyncService</tt> is a fully asynchronous HTTP server side protocol
@@ -129,18 +130,10 @@ public class HttpAsyncService implements
final HttpAsyncExpectationVerifier expectationVerifier,
final HttpParams params) {
super();
- if (httpProcessor == 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");
- }
+ Args.notNull(httpProcessor, "HTTP processor");
+ Args.notNull(connStrategy, "Connection reuse strategy");
+ Args.notNull(responseFactory, "Response factory");
+ Args.notNull(params, "HTTP parameters");
this.httpProcessor = httpProcessor;
this.connStrategy = connStrategy;
this.responseFactory = responseFactory;
@@ -747,9 +740,7 @@ public class HttpAsyncService implements
}
public void submitResponse(final HttpAsyncResponseProducer responseProducer) {
- if (responseProducer == null) {
- throw new IllegalArgumentException("Response producer may not be null");
- }
+ Args.notNull(responseProducer, "Response producer");
synchronized (this) {
if (this.completed) {
throw new IllegalStateException("Response already submitted");
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpHandlerBase.java Wed Aug 8 19:56:38 2012
@@ -38,6 +38,7 @@ import org.apache.http.nio.NHttpConnecti
import org.apache.http.nio.util.ByteBufferAllocator;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.util.Args;
/**
* @since 4.0
@@ -63,18 +64,10 @@ public abstract class NHttpHandlerBase {
final ByteBufferAllocator allocator,
final HttpParams params) {
super();
- if (httpProcessor == null) {
- throw new IllegalArgumentException("HTTP processor may not be null.");
- }
- if (connStrategy == null) {
- throw new IllegalArgumentException("Connection reuse strategy may not be null");
- }
- if (allocator == null) {
- throw new IllegalArgumentException("ByteBuffer allocator may not be null");
- }
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
+ Args.notNull(httpProcessor, "HTTP processor");
+ Args.notNull(connStrategy, "Connection reuse strategy");
+ Args.notNull(allocator, "ByteBuffer allocator");
+ Args.notNull(params, "HTTP parameters");
this.httpProcessor = httpProcessor;
this.connStrategy = connStrategy;
this.allocator = allocator;
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java Wed Aug 8 19:56:38 2012
@@ -54,12 +54,13 @@ import org.apache.http.nio.util.ContentO
import org.apache.http.nio.util.DirectByteBufferAllocator;
import org.apache.http.nio.util.SharedInputBuffer;
import org.apache.http.nio.util.SharedOutputBuffer;
-import org.apache.http.params.HttpParams;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.params.DefaultedHttpParams;
+import org.apache.http.params.HttpParams;
import org.apache.http.protocol.ExecutionContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.util.Args;
/**
* Client protocol handler implementation that provide compatibility with
@@ -114,12 +115,8 @@ public class ThrottlingHttpClientHandler
final Executor executor,
final HttpParams params) {
super(httpProcessor, connStrategy, allocator, params);
- if (execHandler == null) {
- throw new IllegalArgumentException("HTTP request execution handler may not be null.");
- }
- if (executor == null) {
- throw new IllegalArgumentException("Executor may not be null");
- }
+ Args.notNull(execHandler, "HTTP request execution handler");
+ Args.notNull(executor, "Executor");
this.execHandler = execHandler;
this.executor = executor;
this.bufsize = this.params.getIntParameter(NIOReactorPNames.CONTENT_BUFFER_SIZE, 20480);
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java Wed Aug 8 19:56:38 2012
@@ -41,8 +41,8 @@ import org.apache.http.HttpResponseFacto
import org.apache.http.HttpStatus;
import org.apache.http.HttpVersion;
import org.apache.http.MethodNotSupportedException;
-import org.apache.http.ProtocolVersion;
import org.apache.http.ProtocolException;
+import org.apache.http.ProtocolVersion;
import org.apache.http.UnsupportedHttpVersionException;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.entity.ByteArrayEntity;
@@ -61,14 +61,15 @@ import org.apache.http.nio.util.ContentO
import org.apache.http.nio.util.DirectByteBufferAllocator;
import org.apache.http.nio.util.SharedInputBuffer;
import org.apache.http.nio.util.SharedOutputBuffer;
-import org.apache.http.params.HttpParams;
import org.apache.http.params.DefaultedHttpParams;
-import org.apache.http.protocol.HttpContext;
+import org.apache.http.params.HttpParams;
import org.apache.http.protocol.ExecutionContext;
+import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpExpectationVerifier;
import org.apache.http.protocol.HttpProcessor;
import org.apache.http.protocol.HttpRequestHandler;
import org.apache.http.protocol.HttpRequestHandlerResolver;
+import org.apache.http.util.Args;
import org.apache.http.util.EncodingUtils;
import org.apache.http.util.EntityUtils;
@@ -128,12 +129,8 @@ public class ThrottlingHttpServiceHandle
final Executor executor,
final HttpParams params) {
super(httpProcessor, connStrategy, allocator, params);
- if (responseFactory == null) {
- throw new IllegalArgumentException("Response factory may not be null");
- }
- if (executor == null) {
- throw new IllegalArgumentException("Executor may not be null");
- }
+ Args.notNull(responseFactory, "Response factory");
+ Args.notNull(executor, "Executor");
this.responseFactory = responseFactory;
this.executor = executor;
this.bufsize = this.params.getIntParameter(NIOReactorPNames.CONTENT_BUFFER_SIZE, 20480);
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ListeningIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ListeningIOReactor.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ListeningIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ListeningIOReactor.java Wed Aug 8 19:56:38 2012
@@ -27,9 +27,9 @@
package org.apache.http.nio.reactor;
+import java.io.IOException;
import java.net.SocketAddress;
import java.util.Set;
-import java.io.IOException;
/**
* ListeningIOReactor represents an I/O reactor capable of listening for
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java Wed Aug 8 19:56:38 2012
@@ -27,19 +27,6 @@
package org.apache.http.nio.reactor.ssl;
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.nio.reactor.EventMask;
-import org.apache.http.nio.reactor.IOSession;
-import org.apache.http.nio.reactor.SocketAccessor;
-import org.apache.http.nio.reactor.SessionBufferStatus;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLEngineResult;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLEngineResult.HandshakeStatus;
-import javax.net.ssl.SSLEngineResult.Status;
-import javax.net.ssl.SSLException;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
@@ -48,6 +35,21 @@ import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import java.nio.channels.SelectionKey;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLEngineResult;
+import javax.net.ssl.SSLEngineResult.HandshakeStatus;
+import javax.net.ssl.SSLEngineResult.Status;
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLSession;
+
+import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.nio.reactor.EventMask;
+import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.nio.reactor.SessionBufferStatus;
+import org.apache.http.nio.reactor.SocketAccessor;
+import org.apache.http.util.Args;
+
/**
* <tt>SSLIOSession</tt> is a decorator class intended to transparently extend
* an {@link IOSession} with transport layer security capabilities based on
@@ -105,12 +107,8 @@ public class SSLIOSession implements IOS
final SSLContext sslContext,
final SSLSetupHandler handler) {
super();
- if (session == null) {
- throw new IllegalArgumentException("IO session may not be null");
- }
- if (sslContext == null) {
- throw new IllegalArgumentException("SSL context may not be null");
- }
+ Args.notNull(session, "IO session");
+ Args.notNull(sslContext, "SSL context");
this.session = session;
this.defaultMode = defaultMode;
this.appEventMask = session.getEventMask();
@@ -423,9 +421,7 @@ public class SSLIOSession implements IOS
}
private synchronized int writePlain(final ByteBuffer src) throws SSLException {
- if (src == null) {
- throw new IllegalArgumentException("Byte buffer may not be null");
- }
+ Args.notNull(src, "Byte buffer");
if (this.status != ACTIVE) {
return -1;
}
@@ -446,9 +442,7 @@ public class SSLIOSession implements IOS
}
private synchronized int readPlain(final ByteBuffer dst) {
- if (dst == null) {
- throw new IllegalArgumentException("Byte buffer may not be null");
- }
+ Args.notNull(dst, "Byte buffer");
if (this.inPlain.position() > 0) {
this.inPlain.flip();
int n = Math.min(this.inPlain.remaining(), dst.remaining());
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java Wed Aug 8 19:56:38 2012
@@ -31,6 +31,7 @@ import java.nio.ByteBuffer;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.io.BufferInfo;
+import org.apache.http.util.Args;
/**
* A buffer that expand its capacity on demand using {@link ByteBufferAllocator}
@@ -61,9 +62,7 @@ public class ExpandableBuffer implements
*/
public ExpandableBuffer(int buffersize, final ByteBufferAllocator allocator) {
super();
- if (allocator == null) {
- throw new IllegalArgumentException("ByteBuffer allocator may not be null");
- }
+ Args.notNull(allocator, "ByteBuffer allocator");
this.allocator = allocator;
this.buffer = allocator.allocate(buffersize);
this.mode = INPUT_MODE;
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java Wed Aug 8 19:56:38 2012
@@ -34,6 +34,7 @@ import java.util.concurrent.locks.Reentr
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.nio.ContentEncoder;
import org.apache.http.nio.IOControl;
+import org.apache.http.util.Args;
/**
* Implementation of the {@link ContentOutputBuffer} interface that can be
@@ -67,9 +68,7 @@ public class SharedOutputBuffer extends
@Deprecated
public SharedOutputBuffer(int buffersize, final IOControl ioctrl, final ByteBufferAllocator allocator) {
super(buffersize, allocator);
- if (ioctrl == null) {
- throw new IllegalArgumentException("I/O content control may not be null");
- }
+ Args.notNull(ioctrl, "I/O content control");
this.ioctrl = ioctrl;
this.lock = new ReentrantLock();
this.condition = this.lock.newCondition();
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingIOSession.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingIOSession.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingIOSession.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/LoggingIOSession.java Wed Aug 8 19:56:38 2012
@@ -52,9 +52,6 @@ public class LoggingIOSession implements
public LoggingIOSession(final IOSession session, final String id, final Log log, final Log wirelog) {
super();
- if (session == null) {
- throw new IllegalArgumentException("I/O session may not be null");
- }
this.session = session;
this.channel = new LoggingByteChannel();
this.id = id;
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/ContentDecoderMock.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/ContentDecoderMock.java?rev=1370923&r1=1370922&r2=1370923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/ContentDecoderMock.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/ContentDecoderMock.java Wed Aug 8 19:56:38 2012
@@ -44,9 +44,6 @@ public class ContentDecoderMock implemen
}
public int read(final ByteBuffer dst) throws IOException {
- if (dst == null) {
- throw new IllegalArgumentException("Byte buffer may not be null");
- }
if (this.completed) {
return -1;
}