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/22 11:14:11 UTC
[jira] [Comment Edited] (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=14106653#comment-14106653 ]
Michael Osipov edited comment on POOL-271 at 8/22/14 9:13 AM:
--------------------------------------------------------------
For instance LANG-753 and JDK's {{Objects}}. I still remember a issue discussion (LANG-1008) why {{Validate}} is not used throughout Lang but only manual IAE are thrown.
was (Author: michael-o):
For instance LANG-753 and JDK's {{Objects}}. I still remember a issue discussion (which I cannot find here for some reason) why {{Validate}} is not used throughout Lang but only manual IAE are thrown.
> 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)