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 B0D90179F9 for ; Sun, 22 Feb 2015 20:55:17 +0000 (UTC) Received: (qmail 66507 invoked by uid 500); 22 Feb 2015 20:55:12 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 66413 invoked by uid 500); 22 Feb 2015 20:55:12 -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 66401 invoked by uid 99); 22 Feb 2015 20:55:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Feb 2015 20:55:12 +0000 Date: Sun, 22 Feb 2015 20:55:12 +0000 (UTC) From: "Phil Steitz (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (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:all-tabpanel ] Phil Steitz updated POOL-284: ----------------------------- Attachment: pool-283-4.patch Some WIP to review and performance test. Passes the (disabled) tests for this issue and POOL-283. Replaces ConcurrentHashMap with a slightly modified StaticBucketMap from Commons Collections. I did not set up configurability; but we could make the allObjects map type configurable, using something like this patch when the requirements of this issue and / or pool-283 are required. > "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: 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 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)