commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject Re: Is invalidateObject() necessary is makeObject() throws exception
Date Fri, 16 Jan 2009 11:29:14 GMT
movie user wrote:
> Hello Everyone,
>
> I have a question on the common pool.
>
> I have a makeObject() method inside the factory class. Now if this method
> throws any exception do I need to do pool.invalidateObject() in the catch
> block.
>   
If I understand your question correctly, the answer is no.  If your 
factory's makeObject throws an exception,  the pool method (borrow or 
add) that invokes the factory method will not catch the exception and no 
object will be added to the pool, so there is nothing to invalidate.

Phil
> e.g
>
> try {
>    pool.borrowObject()l
> }
>  catch (Exception e) {
>    pool.invalidateObject();
>  }
>
> Factory class
>
> public Object makeObject() throws Exception {
>   try {
>
>   } catch (Exception e) {
>      throw e;
>     }
>   return <some object>
>
> }
>
>   


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


Mime
View raw message