commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <>
Subject [jira] Resolved: (CONFIGURATION-424) HierachicalINIConfiguration has problems with configurations only containing a global section
Date Thu, 28 Oct 2010 20:27:24 GMT


Oliver Heger resolved CONFIGURATION-424.

       Resolution: Fixed
    Fix Version/s: 1.7

A fix was applied to subversion in revision 1028460. Thanks for the report.

> HierachicalINIConfiguration has problems with configurations only containing a global
> ---------------------------------------------------------------------------------------------
>                 Key: CONFIGURATION-424
>                 URL:
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Format
>            Reporter: André Weihe
>            Assignee: Oliver Heger
>            Priority: Critical
>             Fix For: 1.7
> HierachicalINIConfiguration#getSections() does not correctly deal with configurations
containing only a globalSection() leading for example to a configuration containing only a
global section to be saved as a zero length file.
> The current code only acknowledges a global section when at least one other named section
is present, if none is present it just returns an empty set.
> Since HierachicalINIConfiguration#save() saves only the contents of the set returned
by getSections() this leads to an ini file being loaded and saved again to be saved as a zero
length file resulting in the loss of all data in the file (thus the critical priority).
> Workaround:
> Create at least one named section
> Proposed fix (sourcecode): 
> Set sections = new ListOrderedSet();
> for (Iterator it = getRootNode().getChildren().iterator(); it.hasNext();)
> {
>     ConfigurationNode node = (ConfigurationNode);
>     if (isSectionNode(node))
>     {
>         sections.add(node.getName());
>     }
>     else
>     {
>         sections.add(null);
>     }
> }
> return sections;
> Beware:
> I have NOT tested this (at all).
> It's just the way I would write this method instead of the way it was written before.
But since I don't know the big picture maybe there was a (good) reason to write the current
version the way it is now so my seemingly easy fix could not work correctly.

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

View raw message