commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: problem with numActive counter
Date Fri, 15 Jan 2010 10:08:53 GMT
On 15/01/2010 10:03, Simone Tripodi wrote:
> Ciao Daniele ;)
> First, I suggest you to start the subject line with [componentname],
> i.e. [POOL] if you're referring commons-pool, otherwise people risk to
> get confused and not able to reply.
> 
> I don't know the Pool so deeply and maybe I didn't understand the
> problem, but reading your code I'm worried 'invalidateObject()' always
> takes 'null' as argument... take a look at this with the
> logger/debugger.

Yep. That's the problem. That call is almost certainly unnecessary. If
want to keep it, wrap it in a <code>if  (obj != null)</code> test.

Mark

> All the best,
> Simo
> 
> On Fri, Jan 15, 2010 at 10:53 AM, Daniele Bonetto
> <daniele.bonetto@dnshosting.it> wrote:
>> Hello everyone!
>>
>> I notice a problem using GenericObjectPool.
>>
>> My code is like this:
>>
>>        Object obj = null;
>>        try
>>        {
>>                obj = this.borrowObject();
>>        }
>>        catch(NoSuchElementException ex)
>>        {
>>            log.error("no such element exception", ex);
>>            this.invalidateObject(obj);
>>            throw new NicProviderPoolException("no such element exception",
>> ex);
>>        }
>>        catch(Exception ex)
>>        {
>>            log.error("exception", ex);
>>            this.invalidateObject(obj);
>>            throw new Exception("exception", ex);
>>        }
>>        return (NicProvider)obj;
>>
>> When the borrowObject throws an exception and i invalidate the
>> borrowedObject the numActive counter was decreased by 1. The problem is that
>> the counter will not be increased in case of exception... So, my numActive
>> counter will be -1 and isn't correct.
>>
>> Someone has noticed this problem too?
>>
>> Thanks in advance,
>> Byez!
>>
>> Daniele Bonetto
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
> 
> 
> 




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


Mime
View raw message