You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Mark Thomas <ma...@apache.org> on 2009/05/25 10:18:47 UTC
Re: [pool] NPE in GKOP borrowObject
Phil Steitz wrote:
> I added (but have not yet committed) the following test case to validate
> the WHEN_EXHAUSTED_GROW contract.
>
> public void testWhenExhaustedGrow() throws Exception {
> pool.setMaxActive(1);
> pool.setMaxTotal(1);
> pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
> for (int i = 0; i < 10; i++) {
> pool.borrowObject("a");
> }
> }
>
> This test causes an NPE in borrowObject. I suspect the problem is here:
>
> if (null == latch.getPair()) {
> try {
> Object obj = _factory.makeObject(key);
> latch.setPair(new ObjectTimestampPair(obj));
> newlyCreated = true;
>
> In this case, the latch may not at this point have a pool associated
> with it, so when later on we do
>
> latch.getPool().decrementInternalProcessingCount();
>
> we get NPE On the pool. Do we even want to do the decrement in this
> case? Do we need to force an allocate() somewhere? Should the
> Latch(key) constructor find or create the pool and assign it?
I see the same NPE. Looking into it now...
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [pool] NPE in GKOP borrowObject
Posted by Mark Thomas <ma...@apache.org>.
Mark Thomas wrote:
> Phil Steitz wrote:
>> I added (but have not yet committed) the following test case to validate
>> the WHEN_EXHAUSTED_GROW contract.
>>
>> public void testWhenExhaustedGrow() throws Exception {
>> pool.setMaxActive(1);
>> pool.setMaxTotal(1);
>> pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
>> for (int i = 0; i < 10; i++) {
>> pool.borrowObject("a");
>> }
>> }
>>
>> This test causes an NPE in borrowObject. I suspect the problem is here:
>>
>> if (null == latch.getPair()) {
>> try {
>> Object obj = _factory.makeObject(key);
>> latch.setPair(new ObjectTimestampPair(obj));
>> newlyCreated = true;
>>
>> In this case, the latch may not at this point have a pool associated
>> with it, so when later on we do
>>
>> latch.getPool().decrementInternalProcessingCount();
>>
>> we get NPE On the pool. Do we even want to do the decrement in this
>> case? Do we need to force an allocate() somewhere? Should the
>> Latch(key) constructor find or create the pool and assign it?
>
> I see the same NPE. Looking into it now...
>
> Mark
Fixed.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org