You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Holger Hoffstätte (JIRA)" <ji...@apache.org> on 2011/02/03 15:43:28 UTC

[jira] Commented: (POOL-183) potential new method for interface ObjectPool: returnAndValidateObject

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

Holger Hoffstätte commented on POOL-183:
----------------------------------------

This looks very confusing. We would be breaking the general interface contract because client code tries to act on behalf of both the pool and the factory, but only "sometimes" - and that is just not its role.
Also if validation is so expensive then nothing would stop a factory from doing so concurrently, while the client can quickly continue to do other things.


> 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