commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Waldhoff, Rodney" <>
Subject [pool] borrowObject() throws Exception?
Date Tue, 12 Mar 2002 15:17:16 GMT
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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message