Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5009D17629 for ; Thu, 5 Feb 2015 22:15:35 +0000 (UTC) Received: (qmail 92195 invoked by uid 500); 5 Feb 2015 22:15:35 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 92097 invoked by uid 500); 5 Feb 2015 22:15:35 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 92076 invoked by uid 99); 5 Feb 2015 22:15:35 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Feb 2015 22:15:35 +0000 Date: Thu, 5 Feb 2015 22:15:34 +0000 (UTC) From: "Thomas Neidhart (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (POOL-284) "Returned object not currently part of this pool" when using mutable objects MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/POOL-284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14308096#comment-14308096 ] Thomas Neidhart commented on POOL-284: -------------------------------------- I have found a paper about performance regression testing. Interestingly, they evaluated both, GenericObjectPool and StaticBucketMap: http://mp.binaervarianz.de/issta2014.pdf The test code is available here: https://github.com/michaelpradel/ConTeGe/tree/SpeedGun > "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 > > I'm using pool to reuse expensive Sets (storing millions of items). Here is a test which fails: > {code} > GenericObjectPoolConfig config = new GenericObjectPoolConfig (); > GenericObjectPool aPool = new GenericObjectPool<> ( new BasePooledObjectFactory () > { > @Override > public Set create () throws Exception > { > return new HashSet(); > } > @Override > public PooledObject wrap ( Set o ) > { > return new DefaultPooledObject<> ( o ); > } > @Override > public void passivateObject ( PooledObject 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 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)