commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject [pool] NPE in GKOP borrowObject
Date Sun, 24 May 2009 19:42:25 GMT
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?

Phil



 

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


Mime
View raw message