You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Michael Osipov (JIRA)" <ji...@apache.org> on 2014/08/21 16:04:10 UTC
[jira] [Reopened] (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:all-tabpanel ]
Michael Osipov reopened POOL-271:
---------------------------------
JDK is not consistent because it has grown over 15 years. This API has ben redesinged with 2.0. At least provide a link to the discussion.
> 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)