You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2013/10/21 08:37:09 UTC

svn commit: r1534035 - in /commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE: ./ src/main/java/org/apache/commons/configuration/ src/test/java/org/apache/commons/configuration/

Author: henning
Date: Mon Oct 21 06:37:08 2013
New Revision: 1534035

URL: http://svn.apache.org/r1534035
Log:
[CONFIGURATION-556] Regression with SystemProperties in 1.8 and 1.9



Added:
    commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestSystemConfigurationRegression.java   (with props)
Modified:
    commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/RELEASE-NOTES.txt
    commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/build.xml
    commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/main/java/org/apache/commons/configuration/MapConfiguration.java

Modified: commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/RELEASE-NOTES.txt?rev=1534035&r1=1534034&r2=1534035&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/RELEASE-NOTES.txt (original)
+++ commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/RELEASE-NOTES.txt Mon Oct 21 06:37:08 2013
@@ -1,7 +1,7 @@
 $Id$
 
                            Commons Configuration Package
-                               Version 1.9
+                               Version 1.10
                                Release Notes
 
 
@@ -14,59 +14,33 @@ The Commons Configuration software libra
 interface which enables an application to read configuration data from a variety
 of sources.
 
-The 1.9 release contains a couple of minor bug fixes and improvements. There
+The 1.10 release contains a couple of minor bug fixes and improvements. There
 are no important new features. The idea is to release the current changes which
 have been applied to the 1.x branch, so that we can start with new development
 on an improved (and partly binary incompatible) 2.0 version.
 
-As there are small changes only, Commons Configuration 1.8 is fully binary
+As there are small changes only, Commons Configuration 1.10 is fully binary
 compatible to the previous version. The minimum required Java version is 1.5.
 
-Following is a complete list of all changes in the new 1.9 release:
+Please note that this release was compiled with the Java 1.6 compiler in 1.5 
+mode. There is a very small chance that this introduced incompatibilities with
+the Java 1.5 runtime. Java 1.5 was EOLed in October 2009. 
 
-BUG FIXES IN 1.9
-================
-* [CONFIGURATION-495]
-  List properties can now be set correctly on a HierarchicalConfiguration if
-  delimiter parsing is disabled.
-
-* [CONFIGURATION-487]
-  DataConfiguration.get() now also works with String properties and if no data
-  type conversion is required.
-
-* [CONFIGURATION-481]
-  Variable substitution in configuration sources declared in a definition file
-  for DefaultConfigurationBuilder now works across multiple sources.
-
- * [CONFIGURATION-477]
-   PropertyListConfiguration now can deal with C-style comments in plist
-   configuration files. Both block and single-line comments are supported.
-
-IMPROVEMENTS AND NEW FEATURES IN 1.9
-====================================
-* [CONFIGURATION-503]
-  Small changes in user guide documentation.
-
-* [CONFIGURATION-502]
-  Improvements of basic features and AbstractConfiguration documentation.
-
-* [CONFIGURATION-501]
-  XMLPropertyListConfiguration no longer swallows exception caused by invalid
-  date properties. Now a warning message is logged.
-
-* [CONFIGURATION-488]
-  Made static DateFormat fields in XMLPropertyListConfiguration.PListNode final
-  and added a note about proper synchronization.
-
-* [CONFIGURATION-483]
-  DatabaseConfiguration now always closes the result set.
-
-* [CONFIGURATION-482]
-  The Import-Package section in the OSGi manifest now uses the
-  resolution:=optional directive for optional dependencies.
+Following is a complete list of all changes in the new 1.10 release:
+
+BUG FIXES IN 1.10
+=================
+
+* [CONFIGURATION-556] Regression with SystemProperties in 1.8 and 1.9
+
+  In 1.7 and before, any change to the system properties was immediately reflected in a 
+  SystemConfiguration object. This behaviour broke in 1.8 and 1.9. This has been fixed
+  for 1.10.
+
+
+
+IMPROVEMENTS AND NEW FEATURES IN 1.10
+=====================================
 
 OTHER CHANGES
 =============
-* The dependency to Commons Codec has been updated to the most recent 1.6
-  version. The older version still works.
-

Modified: commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/build.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/build.xml?rev=1534035&r1=1534034&r2=1534035&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/build.xml (original)
+++ commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/build.xml Mon Oct 21 06:37:08 2013
@@ -22,7 +22,7 @@
   <property name="component.propfile" value="${basedir}/build.properties"/>
   <property file="${component.propfile}"/>
 
-  <property name="component.final.name" value="commons-configuration-1.9"/>
+  <property name="component.final.name" value="commons-configuration-1.10"/>
   <property name="build.dir" value="target"/>
   <property name="build.classes.dir" value="${build.dir}/classes"/>
   <property name="src.java.dir" value="src/main/java"/>

Modified: commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/main/java/org/apache/commons/configuration/MapConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/main/java/org/apache/commons/configuration/MapConfiguration.java?rev=1534035&r1=1534034&r2=1534035&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/main/java/org/apache/commons/configuration/MapConfiguration.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/main/java/org/apache/commons/configuration/MapConfiguration.java Mon Oct 21 06:37:08 2013
@@ -17,12 +17,14 @@
 
 package org.apache.commons.configuration;
 
+import java.util.AbstractMap;
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 
 /**
  * <p>
@@ -255,16 +257,37 @@ public class MapConfiguration extends Ab
      * @param props the {@code Properties} to be copied
      * @return a newly created map with all string keys of the properties
      */
-    private static Map<String, Object> convertPropertiesToMap(Properties props)
+    private static Map<String, Object> convertPropertiesToMap(final Properties props)
     {
-        Map<String, Object> map = new HashMap<String, Object>();
-        for (Map.Entry<Object, Object> e : props.entrySet())
-        {
-            if (e.getKey() instanceof String)
+        return new AbstractMap<String, Object>() {
+
+            @Override
+            public Set<Map.Entry<String, Object>> entrySet()
             {
-                map.put((String) e.getKey(), e.getValue());
+                Set<Map.Entry<String, Object>> entries = new HashSet<Map.Entry<String, Object>>();
+                for (final Map.Entry<Object, Object> propertyEntry : props.entrySet()) {
+                    if (propertyEntry.getKey() instanceof String) {
+                        entries.add(new Map.Entry<String, Object>() {
+
+                            public String getKey()
+                            {
+                                return propertyEntry.getKey().toString();
+                            }
+
+                            public Object getValue()
+                            {
+                                return propertyEntry.getValue();
+                            }
+
+                            public Object setValue(Object value)
+                            {
+                                throw new UnsupportedOperationException();
+                            }
+                        });
+                    }
+                }
+                return entries;
             }
-        }
-        return map;
+        };
     }
 }

Added: commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestSystemConfigurationRegression.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestSystemConfigurationRegression.java?rev=1534035&view=auto
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestSystemConfigurationRegression.java (added)
+++ commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestSystemConfigurationRegression.java Mon Oct 21 06:37:08 2013
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.configuration;
+
+import org.junit.Test;
+import org.junit.Assert;
+
+import java.util.UUID;
+
+public class TestSystemConfigurationRegression
+{
+    @Test
+    public void testSystemPropertiesRegression()
+    {
+        SystemConfiguration sc = new SystemConfiguration();
+        int oldSize = sc.getMap().size();
+        System.setProperty(UUID.randomUUID().toString(), "x");
+        Assert.assertEquals(oldSize + 1, sc.getMap().size());
+    }
+}

Propchange: commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestSystemConfigurationRegression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestSystemConfigurationRegression.java
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision