You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "André Weihe (JIRA)" <ji...@apache.org> on 2010/10/15 23:04:35 UTC
[jira] Created: (CONFIGURATION-424) HierachicalINIConfiguration has
problems with configurations only containing a global section
HierachicalINIConfiguration has problems with configurations only containing a global section
---------------------------------------------------------------------------------------------
Key: CONFIGURATION-424
URL: https://issues.apache.org/jira/browse/CONFIGURATION-424
Project: Commons Configuration
Issue Type: Bug
Components: Format
Reporter: André Weihe
Priority: Critical
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) it.next();
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.
[jira] Resolved: (CONFIGURATION-424) HierachicalINIConfiguration
has problems with configurations only containing a global section
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-424?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
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 section
> ---------------------------------------------------------------------------------------------
>
> Key: CONFIGURATION-424
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-424
> 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) it.next();
> 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.