You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Bhandari, Makarand" <MB...@WebsterBank.com> on 2005/05/09 22:18:49 UTC

[CommonPool] Behavior of GenericPool

Folks,

I'm trying to use Common Pool's GenericObjectPool in a project. The
documentation says that it uses a FIFO (First In First Out) behavior
that makes sure each object is regularly used (helps preventing
time-outs).

In my code, I add a bunch of objects to the pool, then borrow and return
them from/to the pool. When I do this, I keep getting the same object
back every time.

I took a look at the addObjectToPool() code and it says:

if((_maxIdle >= 0) && (_pool.size() >= _maxIdle)) {

shouldDestroy = true;

} else if(success) {

_pool.addFirst(new ObjectTimestampPair(obj)); }

Shouldn't this be _pool.addLast(new ..) ?? addFirst() causes the
returned object to sit at the front of the stack and is returned to you
on the next borrow. I'm trying to do some kind of load balancing among
all the connections in the pool and this throws me off.

Thanks,

Mak.          



**********************************************************************
PRIVILEGED AND CONFIDENTIAL: This communication, including attachments, is for the exclusive use of addressee and may contain proprietary, confidential or privileged information. If you are not the intended recipient, any use, copying, disclosure, dissemination or distribution is strictly prohibited. If you're not the intended recipient, please notify the sender immediately by return email and delete this communication and destroy all copies. 
                    **************************************************
Email containing sensitive information will be sent using ZixMail Secure Messaging.
If you need assistance in accessing a Secure Message, click on the link below http://www.zixit.com/support/zixmailnethelp.htm#4.0 or contact ZixCorp Support at support@zixcorp.com or 888-576-4949.  {WBE}
**********************************************************************