Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-75

[configuration] HierarchicalXMLConfiguration.setProperty() deletes subelements

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: PC

      Description

      Hello,

      I just identified a new issue with HierarchicalXMLConfiguration. The method
      setProperty does not sets a property correctly.

      Try out this simple piece of code:

      Configuration myHierarchicalXMLConfig = new HierarchicalXMLConfiguration();
      Configuration myXMLConfig = new XMLConfiguration();
      myHierarchicalXMLConfig.setProperty("A.B", "valueAB");
      myHierarchicalXMLConfig.setProperty("A", "valueA");
      myXMLConfig.setProperty("A.B", "valueAB");
      myXMLConfig.setProperty("A", "valueA");
      System.out.println("myHierarchicalXMLConfig.getProperty(\"A.B\")"
      + myHierarchicalXMLConfig.getProperty("A.B"));
      System.out.println("myXMLConfig.getProperty(\"A.B\")"
      + myXMLConfig.getProperty("A.B"));

      The output on my WinXP system with the 1.0 release of commons configuration
      using Java 1.4.2_06 is the following:

      myHierarchicalXMLConfig.getProperty("A.B")null
      myXMLConfig.getProperty("A.B")valueAB

      I would expect both implementations of the interface Configuration to behave the
      same way. This means that also myHierarchicalXMLConfig would keep its property
      "A.B" with the associated value "valueAB" after inserting the key "A".

      The problem occurs in a real world scenario, if I allow my application to change
      values stored in the configuration before, i.e., if I try to set a new value for
      "A" after the whole configuration has been read in.
      Just using XMLConfiguration instead serves as a workaround, but I cannot save a
      XMLConfiguration at the moment (see solved issue 32240).

      It would be nice, if this could be fixed.

      Best regards,

      Christian Kemmer

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Christian Kemmer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development