commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz (JIRA)" <j...@apache.org>
Subject [jira] Commented: (POOL-183) potential new method for interface ObjectPool<T>: returnAndValidateObject
Date Thu, 03 Feb 2011 19:05:28 GMT

    [ https://issues.apache.org/jira/browse/POOL-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12990240#comment-12990240
] 

Phil Steitz commented on POOL-183:
----------------------------------

I agree that adding the exact method above to the *interface* is not desirable (IMO).  I think
the use case is legitimate; however, and I could see it addressed in at least three ways:

1. As suggested, but added to the GenericObjectPool (GOP) implementation, not the ObjectPool
interface
2. Have GOP expose the factory's validate method
3. Add validate to the ObjectPool interface

I think 2 is probably the best.  Then the code example above becomes

{code}
Object o = pool.borrowObject();
try { ...
    o.doStuff();
    ...
    pool.returnObject(o);
} catch(Exception e) {
   if (!pool.validate(o)) {
   pool.invalidate(o);
} else {
pool.returnObject(o);
}
{code}

> potential new method for interface ObjectPool<T>: returnAndValidateObject
> -------------------------------------------------------------------------
>
>                 Key: POOL-183
>                 URL: https://issues.apache.org/jira/browse/POOL-183
>             Project: Commons Pool
>          Issue Type: New Feature
>    Affects Versions: 2.0
>            Reporter: Zoltan Farkas
>            Priority: Minor
>
> Would it be possible to add a method:
> void returnAndValidateObject(T obj) throws Exception
> In general I was thinking of the following use case:
> Object o = pool.borrowObject();
> try
> {
>     .........
>     o.doStuff();
>     .........
>     pool.returnObject(o);
> }
> catch(Exception e)
> {
>     // not sure what the cause is, let's make sure o is valid.
>     pool.returnAndValidateObject(o);
> }
> the reason is that validation in general is an expensive operation, and enabling 
> it all the time is inpractical.
> any thoughts ?

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message