[ 
https://issues.apache.org/jira/browse/POOL-94?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12490673
 ] 

Phil Steitz commented on POOL-94:
---------------------------------

Another "bad thing" that can happen if an object instance is returned to the 
pool twice is that it will end up included in the idle object pool twice, so 
could get returned to two different clients on subsequent borrowObject calls.  
For example, with maxActive set to 3 on the pool, pool 1.1, 1.2 and 1.3 will 
all return object1 on the first and third call in the second set of 
borrowObjects below:

// Check  out three Foo things - assume factory makes them distinguishable
Foo object1 = (Foo) pool.borrowObject();
Foo object2 = (Foo) pool.borrowObject();
Foo object3 = (Foo) pool.borrowObject();

// Return two, but one of them twice
pool.returnObject(object1);
pool.returnObject(object2);
pool.returnObject(object1);

// Pool now thinks there are three available, and object1 is in idle instance 
pool twice
object1 = (Foo) pool.borrowObject();
object2 = (Foo) pool.borrowObject();
object3 = (Foo) pool.borrowObject();

At this point, object1 and object3 are the same.

The moral of the story here is that when using pool 1.x, user code must ensure 
that instances are not returned to the pool twice in sequence (i.e, without 
being borrowed again).  

> GenericObjectPool allows checking in of previously checked in objects
> ---------------------------------------------------------------------
>
>                 Key: POOL-94
>                 URL: https://issues.apache.org/jira/browse/POOL-94
>             Project: Commons Pool
>          Issue Type: New Feature
>    Affects Versions: 1.3
>         Environment: JDK 1.4.2, web application running under Tomcat 5.0.25
>            Reporter: Tim McCollough
>            Priority: Minor
>
> I am using GenericObjectPool to store a pool of socket connections. While 
> debugging the application I noticed that the result of GetNumActive() was 
> becoming more and more negative, while the GetNumIldle() count was ever 
> increasing. Further debug showed that my application was returning the same 
> connection more than once and the GenericObjectPool implementation accepted 
> the return silently and decremented the active count and incremented the idle 
> count.
> I don't object to GenericObjectPool allowing multiple returns on the same 
> object, but the bookkeeping problem will lead to bad things happening in the 
> pool management code.
> I am investigating what it would take to fix GenericObjectPool but since I am 
> inexperienced in these commons projects I don't know what I should do from 
> here.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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

Reply via email to