commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <>
Subject [jira] Commented: (CONFIGURATION-407) HierarchicalINIConfiguration can throw an exception if the global section is accessed concurrently
Date Mon, 08 Feb 2010 22:55:28 GMT


Sebb commented on CONFIGURATION-407:

If the same INIConfiguration instance is shared between threads, and one updates the shared
config, then in the absence of synchronization, the other threads won't necessarily see the
updated values. This is because the JVM is allowed to cache values in both the writer and
reader threads.

In order to ensure that cached values are correctly published, some form on synch. is needed.

For example, the reader has to synch. on the same object as the writer.
Or one can use volatile.

Or, for example the configuration can be created in one thread, which then starts other threads
that read it. Thread.start() acts as the lock in this case.
But if the writer thread subsequently changes the shared state, additional synch. will be
needed to guarantee safe publication to the existing threads.

By the way, the test case does not appear to test changes to the global INIConfiguration.

> HierarchicalINIConfiguration can throw an exception if the global section is accessed
> --------------------------------------------------------------------------------------------------
>                 Key: CONFIGURATION-407
>                 URL:
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.6
>            Reporter: Oliver Heger
>            Assignee: Oliver Heger
>             Fix For: 1.7
> If the global section of a hierarchical INI configuration is requested, a new ViewNode
is created which becomes the root node of a new configuration for the global section. Nodes
representing properties of the global section are added to this ViewNode. This operation temporarily
changes the parent node of these nodes which may cause problems if the method is called by
multiple threads concurrently. Because access to a section is a read-only operation, this
should be thread-safe.
> The probability that this error happens is pretty low IMO. Therefore it should be hard
to create a unit test.
> The issue can be fixed by synchronizing the add operation to the ViewNode.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message