[
https://issues.apache.org/jira/browse/POOL-271?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14106632#comment-14106632
]
Benedikt Ritter commented on POOL-271:
--------------------------------------
[~michael-o], from where do you draw the conclusion that throwing NPE is Java
convention?
> 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)