commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: [pool] NPE in GKOP borrowObject
Date Mon, 25 May 2009 08:18:47 GMT
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


Mime
View raw message