commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Kinser (JIRA)" <j...@apache.org>
Subject [jira] Updated: (CONFIGURATION-390) AbstractHierarchicalFileConfiguration is not thread safe
Date Fri, 25 Sep 2009 17:32:16 GMT

     [ https://issues.apache.org/jira/browse/CONFIGURATION-390?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Stephen Kinser updated CONFIGURATION-390:
-----------------------------------------

    Attachment: TestSuite.txt
                configtest.tar.gz

I also get this problem randomly when multithreaded, though I don't know if this belongs in
a different JIRA:

testMultiThreadedAccess(TestReloading)  Time elapsed: 0.018 sec  <<< FAILURE!
java.lang.IllegalStateException: Node cannot be modified when added to a parent!
        at org.apache.commons.configuration.tree.DefaultConfigurationNode.checkState(DefaultConfigurationNode.java:454)
        at org.apache.commons.configuration.tree.DefaultConfigurationNode.setAttribute(DefaultConfigurationNode.java:290)
        at org.apache.commons.configuration.tree.DefaultConfigurationNode.addChild(DefaultConfigurationNode.java:184)
        at org.apache.commons.configuration.tree.ViewNode.addChild(ViewNode.java:78)
        at org.apache.commons.configuration.tree.ViewNode.appendChildren(ViewNode.java:114)
        at org.apache.commons.configuration.CombinedConfiguration$ConfigData.getTransformedRoot(CombinedConfiguration.java:847)
        at org.apache.commons.configuration.CombinedConfiguration.constructCombinedNode(CombinedConfiguration.java:699)
        at org.apache.commons.configuration.CombinedConfiguration.getRootNode(CombinedConfiguration.java:542)
        at org.apache.commons.configuration.HierarchicalConfiguration.fetchNodeList(HierarchicalConfiguration.java:926)
        at org.apache.commons.configuration.CombinedConfiguration.fetchNodeList(CombinedConfiguration.java:653)
        at org.apache.commons.configuration.HierarchicalConfiguration.getProperty(HierarchicalConfiguration.java:332)
        at org.apache.commons.configuration.AbstractConfiguration.resolveContainerStore(AbstractConfiguration.java:1160)
        at org.apache.commons.configuration.AbstractConfiguration.getString(AbstractConfiguration.java:1035)
        at org.apache.commons.configuration.AbstractConfiguration.getString(AbstractConfiguration.java:1018)
        at TestReloading.testMultiThreadedAccess(TestReloading.java:73)


> 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: 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.


Mime
View raw message