Description
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))
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.