Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-6

[configuration] XMLConfiguration inconsistency towards empty values

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.2
    • Component/s: None
    • Labels:
      None
    • Bugzilla Id:
      35963

      Description

      Empty values are not read correctly from XML files : when a XML file contains an
      empty element, the corresponding keys are not present in the configuration, but
      an empty string can be saved!

      Consider the following code :

      XMLConfiguration config = new XMLConfiguration();
      config.setProperty("foo.bar", "");
      config.save("config.xml");
      System.out.println("Config saved!");
      System.out.println("foo.bar in config1 = "+config.getProperty("foo.bar"));
      XMLConfiguration config2 = new XMLConfiguration("config.xml");
      System.out.println("foo.bar in config2= "+config2.getProperty("foo.bar"));

      The output is :

      foo.bar in config1 = ''
      foo.bar in config2 = 'null'

      the file config.xml contains :

      <configuration>
      <foo>
      <bar/>
      </foo>
      </configuration>

      this also does not allow to distinguish between an empty value and a missing key.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                e.lacazedieu@lectra.com Etienne Lacazedieu
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: