You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Adrian Crum (JIRA)" <ji...@apache.org> on 2014/08/22 00:28:14 UTC
[jira] [Commented] (POOL-271) Make standard use of
NullPoinerException instead of IllegalArgumentException
[ https://issues.apache.org/jira/browse/POOL-271?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14106068#comment-14106068 ]
Adrian Crum commented on POOL-271:
----------------------------------
Here's the link: http://en.wikipedia.org/wiki/Chicken_or_the_egg
> 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)