Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 16775 invoked from network); 26 Sep 2009 15:37:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Sep 2009 15:37:40 -0000 Received: (qmail 75898 invoked by uid 500); 26 Sep 2009 15:37:40 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 75772 invoked by uid 500); 26 Sep 2009 15:37:40 -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 75757 invoked by uid 99); 26 Sep 2009 15:37:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 Sep 2009 15:37:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 Sep 2009 15:37:37 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 03DB7234C004 for ; Sat, 26 Sep 2009 08:37:16 -0700 (PDT) Message-ID: <1241032855.1253979436001.JavaMail.jira@brutus> Date: Sat, 26 Sep 2009 08:37:16 -0700 (PDT) From: "Oliver Heger (JIRA)" To: issues@commons.apache.org Subject: [jira] Updated: (CONFIGURATION-390) AbstractHierarchicalFileConfiguration is not thread safe In-Reply-To: <1526663720.1245772207345.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CONFIGURATION-390?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Oliver Heger updated CONFIGURATION-390: --------------------------------------- Attachment: commons-configuration-390.patch I have created a unit test that fails more reliably and a proposed fix. The idea is that the lock used by the {{reload()}} method is exposed so that external synchronization can be performed. {{AbstractHierarchicalFileConfiguration}} now synchronizes at this lock in its {{getProperty()}} method. This does not fix all problems with this architecture, e.g. other methods like {{isEmpty()}} or {{containsKey()}} should be treated in a similar way. But concurrent property reads should now be possible. > AbstractHierarchicalFileConfiguration is not thread safe > -------------------------------------------------------- > > Key: CONFIGURATION-390 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-390 > Project: Commons Configuration > Issue Type: Bug > Components: File reloading > Affects Versions: 1.6 > Reporter: Emmanuel Bourg > Fix For: 1.7 > > Attachments: commons-configuration-390.patch, configtest.tar.gz, TestSuite.txt > > > AbstractHierarchicalFileConfiguration doesn't implement the same locking mechanism found in AbstractFileConfiguration. The consequence is that getting a property while the configuration is being reloaded by another thread can return an invalid result. > This can be demonstrated by changing testDeadlockWithReload() in TestCombinedConfiguration to use an XMLConfiguration instead of a PropertiesConfiguration. > Here is a reduced test case: > {code:java} > public void testConcurrentGetAndReload() throws Exception > { > //final FileConfiguration config = new PropertiesConfiguration("test.properties"); > final FileConfiguration config = new XMLConfiguration("test.xml"); > config.setReloadingStrategy(new FileAlwaysReloadingStrategy()); > assertTrue("Property not found", config.getProperty("test.short") != null); > new Thread() > { > public void run() > { > for (int i = 0; i < 1000; i++) > { > config.reload(); > } > } > }.start(); > > for (int i = 0; i < 1000; i++) > { > assertTrue("Property not found", config.getProperty("test.short") != null); // failure here > } > } > {code} > The test doesn't always fail. It does about 50% of the time. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.