commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom van den Berge" <>
Subject [Pool] Returning non-pool objects
Date Mon, 20 Sep 2004 21:08:14 GMT

The javadoc of ObjectPool.returnObject() states that the returned object
*must* by contract be obtained by borrowObject().

Unfortunately the method does not throw an Exception when an object is
returned that was never borrowed from the pool. That is, none of the
provided implementation do so, nor does the javadoc define this in the

Maybe I'm overlooking some detail, but I think it would be a very nice
enhancement of the API to let it throw an appropriate exception if the
returned object is not 'recognized'. It will greatly improve the integrity
of the pool.

In the implementation I see that the reference to a pooled object is lost
as soon as it is borrowed. I think maintaining a set of references to
those objects can probably be implemented easily.

It also allows other features, e.g. triggering alarms on objects that are
borrowed longer than some time, or whatever.

Let me know what you think.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message