Bug 104047 [Dialogs] Incorrect Output from DialogSettings.save()
The XML produced by the DialogSettings.save() method is not correct. If multiple arrayItems exist, every element after the first will have an extra "value" attribute. Here is a code snipet to illustrate: IDialogSettings export = new DialogSettings("Example"); String[] values1 = { "value1", "value2" }; export.put("key1", values1 ); String[] values2 = { "value3", "value4" }; export.put("key2", values2 ); try { export.save("C:\\test.xml"); } catch (IOException e) { // Do Nothing } The output of this is: <?xml version="1.0" encoding="UTF-8"?> <section name="Example"> <list key="key1"> <item value="value1"/> <item value="value2"/> </list> <list key="key2" value="value2"> <item value="value3"/> <item value="value4"/> </list> </section> As you can see, the second "list" has an attribute "value" which it shouldn't. The reason is the value from the previous list element is not cleared before writing the second element. I.E. "value2" from the first list element is used as the value attribute for the second list element. Suggested fix: In DialogSettings.save(), add another "attributes.clear();" for the loop that iterates over the aarryItems field.
bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/DialogSettings.java
/* (non-Javadoc)
     * Load the setting from the <code>document</code>
     */
    private void load(Document document, Element root) {
        name = root.getAttribute(TAG_NAME);
        NodeList l = root.getElementsByTagName(TAG_ITEM);
        for (int i = 0; i < l.getLength(); i++) {
            Node n = l.item(i);
            if (root == n.getParentNode()) {
                String key = ((Element) l.item(i)).getAttribute(TAG_KEY);
                String value = ((Element) l.item(i)).getAttribute(TAG_VALUE);
                items.put(key, value);
            }
        }
        l = root.getElementsByTagName(TAG_LIST);
        for (int i = 0; i < l.getLength(); i++) {
            Node n = l.item(i);
            if (root == n.getParentNode()) {
                Element child = (Element) l.item(i);
                String key = child.getAttribute(TAG_KEY);
                NodeList list = child.getElementsByTagName(TAG_ITEM);
                List valueList = new ArrayList();
                for (int j = 0; j < list.getLength(); j++) {
                    Element node = (Element) list.item(j);
                    if (child == node.getParentNode()) {
                        valueList.add(node.getAttribute(TAG_VALUE));
                    }
                }
                String[] value = new String[valueList.size()];
                valueList.toArray(value);