commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <>
Subject Re: [pool] getNumActive returning -1
Date Wed, 08 Jun 2011 16:04:56 GMT
On 6/8/11 6:31 AM, Mark Thomas wrote:
> On 06/06/2011 08:34, Phil Steitz wrote:
>> On 6/5/11 7:32 PM, Phil Steitz wrote:
>>> The AbandonedObjectPool test case that I just commented out in
>>> [dbcp] trunk is failing because GOP getNumActive returns -1.  My
>>> first thought was that this is a timing issue due to lack of
>>> synchronization in invalidate and general non-protection of
>>> _allObjects and _idleObjects; but I can't demonstrate this.  Looking
>>> into it now...
>> I found the problem. The test object class was not threadsafe,
>> resulting in multiple equal instances generated by the factory. 
>> This results in returnObject replacing rather than duplicating
>> instances in _allObjects, which causes _allObjects to have fewer
>> instances than _idleObjects.  We need to think about this setup a
>> little, as it will break if equal instances are ever generated by
>> object factories and in circulation at the same time.  I think it is
>> a reasonable expectation that distinct instances generated by object
>> factories must not be equal; but this is a new requirement and it
>> needs to be documented and we might want to consider a guard for it.
> Good catch. I'm not sure I would have found that anywhere near that quickly.

Thanks!  Credit belongs to the [dbcp] AbandonedObjectPool test case,
though :)
> I'll look into putting a guard into pool for this.

Could also be that we should make _allObjects and _idleObjects have
the same semantics wrt equal instances, too.

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

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

View raw message