I tested a simple scenario where I return the same object several times:
                PoolableJmsTemplateFactory pjtf = new 
PoolableJmsTemplateFactory();
                pjtf.setConnectionFactory(connectionFactory);
                ObjectPool pool = new SoftReferenceObjectPool(pjtf);
                System.out.println("Idle templates:"+pool.getNumIdle());
                JmsTemplate jmsTemplate = (JmsTemplate)pool.borrowObject();
                System.out.println("Active templates:"+pool.getNumActive());
                JmsTemplate jmsTemplate2 = (JmsTemplate)pool.borrowObject();
                System.out.println("Active templates:"+pool.getNumActive());
                pool.returnObject(jmsTemplate);
                System.out.println("Active templates:"+pool.getNumActive());
                pool.returnObject(jmsTemplate2);
                System.out.println("Active templates:"+pool.getNumActive());
                System.out.println("Idle templates:"+pool.getNumIdle());
                pool.returnObject(jmsTemplate2);
                pool.returnObject(jmsTemplate2);
                System.out.println("Active templates:"+pool.getNumActive());
                System.out.println("Idle templates:"+pool.getNumIdle());

What I get is a very unpleasant result:

Idle templates:0
Active templates:1
Active templates:2
Active templates:1
Active templates:0
Idle templates:2
Active templates:-2
Idle templates:4

The pool let me return the object several times!
Shouldn't it throw an exception or at least not have negative number of
active objects?

On top of that, when I tried to borrow objects again the same pool, the same
object was returned several times. This is even worse than the negative
number of active objects.

Why is it implemented in such a way?
-- 
View this message in context: 
http://www.nabble.com/-POOL--you-can-return-your-object-several-times--tp17613295p17613295.html
Sent from the Commons - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to