You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Sandy McArthur (JIRA)" <ji...@apache.org> on 2006/05/16 21:20:06 UTC

[jira] Closed: (POOL-34) Add invalidateObject() method to ObjectPool

     [ http://issues.apache.org/jira/browse/POOL-34?page=all ]
     
Sandy McArthur closed POOL-34:
------------------------------


> Add invalidateObject() method to ObjectPool
> -------------------------------------------
>
>          Key: POOL-34
>          URL: http://issues.apache.org/jira/browse/POOL-34
>      Project: Commons Pool
>         Type: Bug

>  Environment: Operating System: other
> Platform: Other
>     Reporter: Nayan Hajratwala
>  Attachments: BaseObjectPool.java_diff, GenericObjectPool.java_diff, ObjectPool.java_diff, SoftReferenceObjectPool.java_diff, StackObjectPool.java_diff
>
> I'll be adding patches for the appropriate files soon.  Following is the note i 
> originally sent to commons-dev
> =============================================================
> Within commons-pool, I'd like to propose adding the following method to the
> ObjectPool 
> interface:
>         public void invalidateObject(Object obj);
> This would be used to address the situation in which you borrow an object from 
> the pool, and then upon use, discover that it is invalid, at which point you 
> need to get another one.
> i.e.:
>         ObjectPool pool = new GenericObjectPool(...);
>         boolean success = false;
>         while (!success) {
>                 try {
>                         SomeConnection sc = (SomeConnection)pool.borrowObject();
>                         sc.someOperation();
>                         success = true;
>                 }
>                 catch (SomeConnectionException e) {
>                         pool.invalidateObject(sc);
>                 }
>         }
> Why not use PoolableObjectFactory's "validateObject" method you ask?
> Well, that requires testing the Object either before or after you use it, which 
> results in an extra call on the object EVERY time you borrow it (or return 
> it).  This is a problem when the operation required to do the testing is 
> expensive.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org