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

Phil Steitz commented on POOL-284:
----------------------------------

Thanks for pointing out the buckets consideration.  I guess there is no way 
around re-creating the map if the setter expands maxTotal beyond the previous 
value.  That may be OK; but will have to be documented carefully if we go this 
way.

The Equator interface idea is interesting.  I was actually thinking more 
conservatively - leave current impl as is and have config option switch to SBM 
with my hacks to basically do (IIUC) what the IdentityEquator does for users 
who need reference identity semantics.  If we can get performance and 
scalability as good with SBM as CHM, then it would make sense to allow Equator 
configurability.

> "Returned object not currently part of this pool" when using mutable objects
> ----------------------------------------------------------------------------
>
>                 Key: POOL-284
>                 URL: https://issues.apache.org/jira/browse/POOL-284
>             Project: Commons Pool
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Valentin Mayamsin
>         Attachments: StaticBucketMap-mods.patch, pool-283-4.patch
>
>
> I'm using pool to reuse expensive Sets (storing millions of items). Here is a 
> test which fails:
> {code}
>         GenericObjectPoolConfig config = new GenericObjectPoolConfig ();
>         GenericObjectPool<Set> aPool = new GenericObjectPool<> ( new 
> BasePooledObjectFactory<Set> ()
>         {
>             @Override
>             public Set create () throws Exception
>             {
>                 return new HashSet();
>             }
>             @Override
>             public PooledObject<Set> wrap ( Set o )
>             {
>                 return new DefaultPooledObject<> ( o );
>             }
>             @Override
>             public void passivateObject ( PooledObject<Set> p ) throws 
> Exception
>             {
>                 p.getObject ().clear ();
>                 super.passivateObject ( p );
>             }
>         }, config );
>         Set set = aPool.borrowObject ();
>         set.add ( new Object () );
>         
>         aPool.returnObject ( set );
> {code}
> This is because GenericObjectPool uses a HashMap<Object, PooledObject> to 
> correlate objects and state. HashMap stores objects correlated to their 
> hashCode. So in case object's state change then hashCode will change, thus 
> Map will fail to correlate this object since it stores old hashCode



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to