commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Migowski <chrismf...@gmail.com>
Subject [commons-configuration] XMLConfiguration XPathExpressionEngine saving Lists error
Date Tue, 24 Mar 2009 09:21:34 GMT
Hi,

is this considered a bug:

If I load a list with commons-configuration, then add new entries to
that list and try to save it back to file, I get a
"java.lang.IllegalArgumentException: prepareAdd: Passed in key must
contain a whitespace!" exception.
If I do not modify the list, saving works.
If I remove entries from the list, saving works as well.

Very simple demo-program:

XML File:
<config>
   <liste>eintrag 1</liste>
   <liste>eintrag 2</liste>
   <liste>eintrag 3</liste>
</config>

program:

    public static void main(String[] args) {
        XMLConfiguration masterconfig;
        try {
            masterconfig = new XMLConfiguration("democonfig.xml");
            masterconfig.setExpressionEngine(new XPathExpressionEngine());

            List<String> test = masterconfig.getList("liste");

            masterconfig.setProperty("liste", test); //ok, no changes
            masterconfig.save();

            test.remove("eintrag 2");
            masterconfig.setProperty("liste", test); //ok, one <liste>
element is removed from file
            masterconfig.save();

            test.add("neuer eintrag");
            masterconfig.setProperty("liste", test); //exception
            masterconfig.save();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

I think commons-configuration should work consistent on all this cases.

best regards,
christian!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message