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

SystemConfiguration copies System.getProperties() instead of directly using it since 1.8

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.8, 1.9
    • 2.0
    • None
    • None

    Description

      In commons-configuration-1.7 the SystemConfiguration directly used the Map of System.getProperties(). Thus when changing the properties inside the SystemConfiguration, the changes were visible in the Map of System.getProperties().

      Since commons-configuration-1.8 the SystemConfiguration creates a new Map as a copy of System.getProperties() and thus changes in the SystemConfiguration Map are not visible in the System.getProperties() Map.

      In 1.7 this super constructor is used by SystemProperties:

      public MapConfiguration(Map map) {
          this.map = map;
      }
      

      In 1.9 this super constructor is used by SystemProperties:

      public MapConfiguration(Properties props) {
          map = convertPropertiesToMap(props);
      }
      

      A fix could look like this:

      public SystemConfiguration() {
          super((Map)System.getProperties());
      }
      

      This breaks the functionality I expected to be able to use SystemConfiguration as a replacement API for accessing and manipulating SystemProperties. For me this is a regression.

      My workaround is currently not to use:

      new SystemConfiguration();
      

      but instead use:

      new MapConfiguration((Map) System.getProperties());
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              subes subes
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: