You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Waldhoff, Rodney" <rw...@us.britannica.com> on 2002/03/12 16:17:16 UTC

[pool] borrowObject() throws Exception?

We talked about this a while back on this list, and everyone who commented
seemed to think it'd be a good idea, but I thought I'd run it by everyone
one more time before actually doing it.  Does anyone have an objection to
making some of the Pool interface methods (like ObjectPool.borrowObject,
PoolableObjectFactory.makeObject, etc.) throw Exception?  

This would help out in components that'd like to throw something other than
a RuntimeException when the factory methods fail  (such as DBCP).  It would
also help to reinforce the "proper" usage of the pool:

Object borrowed = null;
try {
  borrowed = pool.borrowObject();
  //... use it
} catch(Excpetion e) {
  if(null != borrowed) { pool.returnObject(borrowed); }
}

which ensures the borrowed object is returned to the pool.

- Rod