commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Thelian <Martin.Thel...@gmx.at>
Subject Re: Is invalidateObject() necessary is makeObject() throws exception
Date Fri, 16 Jan 2009 11:04:34 GMT
Hi!

movie user schrieb:
> 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 an exceptions is thrown during pooled-object creation, the exception
will be propagated to the code requesting the object. So you have
nothing to invalidate in your code.

If you have the following code
|>  Object obj = null;
|>  try {
|>      obj = pool.borrowObject();
|>      [...]
|>  } catch(Exception e) {
|>      if (obj != null) pool.invalidateObject(obj);
|>  }

then obj is null in this situation.

Regards,
Martin


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


Mime
View raw message