Michael Osipov created POOL-271:
-----------------------------------

             Summary: Make standard use of NullPoinerException instead of 
IllegalArgumentException
                 Key: POOL-271
                 URL: https://issues.apache.org/jira/browse/POOL-271
             Project: Commons Pool
          Issue Type: Improvement
    Affects Versions: 2.2
            Reporter: Michael Osipov


{{IllegalArgumentException}} is abused in several spots where a 
{{NullPointerException}} is appropriate as per Java convention:

{noformat}
$ grep -r "throw new IllegalArgumentException" .
./org/apache/commons/pool2/impl/BaseGenericObjectPool.java:            throw 
new IllegalArgumentException(
./org/apache/commons/pool2/impl/BaseGenericObjectPool.java:            throw 
new IllegalArgumentException(
./org/apache/commons/pool2/impl/BaseGenericObjectPool.java:            throw 
new IllegalArgumentException(
./org/apache/commons/pool2/impl/LinkedBlockingDeque.java:        if (capacity 
<= 0) throw new IllegalArgumentException();
./org/apache/commons/pool2/impl/LinkedBlockingDeque.java:            throw new 
IllegalArgumentException();
./org/apache/commons/pool2/impl/LinkedBlockingDeque.java://             throw 
new IllegalArgumentException();
./org/apache/commons/pool2/impl/GenericKeyedObjectPool.java:            throw 
new IllegalArgumentException("factory may not be null");
./org/apache/commons/pool2/impl/GenericObjectPool.java:            throw new 
IllegalArgumentException("factory may not be null");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("keyedPool must not be null.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("minIdle must be non-negative.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("keyedPool must not be null.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("key must not be null.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("minIdle must be non-negative.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("keys must not be null.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("pool must not be null.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("keyedPool must not be null.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("key must not be null.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("keys must not be null.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("pool must not be null.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("pool must not be null.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("factor must be positive.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("keyedPool must not be null.");
./org/apache/commons/pool2/PoolUtils.java:            throw new 
IllegalArgumentException("factor must be positive.");
./org/apache/commons/pool2/PoolUtils.java:                throw new 
IllegalArgumentException("pool must not be null.");
./org/apache/commons/pool2/PoolUtils.java:                throw new 
IllegalArgumentException(
./org/apache/commons/pool2/PoolUtils.java:                throw new 
IllegalArgumentException("pool must not be null.");
./org/apache/commons/pool2/PoolUtils.java:                throw new 
IllegalArgumentException(
./org/apache/commons/pool2/PoolUtils.java:                throw new 
IllegalArgumentException("factory must not be null.");
./org/apache/commons/pool2/PoolUtils.java:                throw new 
IllegalArgumentException(
./org/apache/commons/pool2/PoolUtils.java:                throw new 
IllegalArgumentException(
{noformat}

Most of the hits apply and should throw a {{NullPointerException}}. There is a 
similar issue with Commons Lang. Alternatively, the {{ValidationUtils}} from 
Commons Lang should be privately imported (shaded) which do the right thing.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to