commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Thomas (Resolved) (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (POOL-207) GenericKeyedObjectPool.clear() has unnecessary null check of objectDequeue
Date Thu, 09 Feb 2012 18:27:59 GMT

     [ https://issues.apache.org/jira/browse/POOL-207?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Mark Thomas resolved POOL-207.
------------------------------

    Resolution: Fixed

Thanks for the analysis.
                
> GenericKeyedObjectPool.clear() has unnecessary null check of objectDequeue
> --------------------------------------------------------------------------
>
>                 Key: POOL-207
>                 URL: https://issues.apache.org/jira/browse/POOL-207
>             Project: Commons Pool
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 2.0
>
>
> GenericKeyedObjectPool.clear() registers the key, and then checks if the objectDeque
obtained by using the key is null.
> Since register creates the key entry in poolMap, the retrieved value should never be
null.
> If it is nullm then AFAICT that is a code bug, which should be reported rather than ignored.
> [If it were possible for the key to be null, then the same null check should be added
to the private destroy method.]
> Also, register returns the ObjectDeque, so the clear() code could be simplified; rather
than
> {code}
> register(key);
> try {
>     ObjectDeque<T> objectDeque = poolMap.get(key);
>     if (objectDeque == null) {
>         return;
>     }
>     ...
> {code}
> the method could use:
> {code}
> ObjectDeque<T> objectDeque = register(key);
> try {
>     ...
> {code}
> Similarly for the private destroy method.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message