Author: henning Date: Mon Oct 21 07:29:03 2013 New Revision: 1534048 URL: http://svn.apache.org/r1534048 Log: [CONFIGURATION-557] Regression: MapConfiguration no longer accepts a Map<String, String>
In 1.7 and before, it was possible to pass an arbitrary Map into the constructor of MapConfiguration. With the generification in 1.8, this actually broke and it was no longer possible to pass in e.g. a Map<String, String> because the signature now required a Map<String, Object>. Changing the constructor to accept a Map<String, ?> restores this. All of this is purely a compiler issue, the runtime itself does not see any of the generics due to the Java type erasure. Added: commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestMapConfigurationRegression.java (with props) Modified: commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/RELEASE-NOTES.txt 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=1534048&r1=1534047&r2=1534048&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 07:29:03 2013 @@ -37,7 +37,15 @@ BUG FIXES IN 1.10 SystemConfiguration object. This behaviour broke in 1.8 and 1.9. This has been fixed for 1.10. +* [CONFIGURATION-557] Regression: MapConfiguration no longer accepts a Map<String, String> + In 1.7 and before, it was possible to pass an arbitrary Map into the constructor of + MapConfiguration. With the generification in 1.8, this actually broke and it was no longer + possible to pass in e.g. a Map<String, String> because the signature now required a + Map<String, Object>. Changing the constructor to accept a Map<String, ?> restores this. + + All of this is purely a compiler issue, the runtime itself does not see any of the generics + due to the Java type erasure. IMPROVEMENTS AND NEW FEATURES IN 1.10 ===================================== 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=1534048&r1=1534047&r2=1534048&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 07:29:03 2013 @@ -104,9 +104,9 @@ public class MapConfiguration extends Ab * * @param map the map */ - public MapConfiguration(Map<String, Object> map) + public MapConfiguration(Map<String, ?> map) { - this.map = map; + this.map = (Map<String, Object>) map; } /** Added: commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestMapConfigurationRegression.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestMapConfigurationRegression.java?rev=1534048&view=auto ============================================================================== --- commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestMapConfigurationRegression.java (added) +++ commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestMapConfigurationRegression.java Mon Oct 21 07:29:03 2013 @@ -0,0 +1,39 @@ +/* + * 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 java.util.Collections; +import java.util.Map; +import java.util.UUID; + +import org.junit.Assert; +import org.junit.Test; + +public class TestMapConfigurationRegression +{ + @Test + public void testMapConfigurationRegression() + { + final String key = UUID.randomUUID().toString(); + final String value = UUID.randomUUID().toString(); + final Map<String, String> map = Collections.singletonMap(key, value); + final MapConfiguration mc = new MapConfiguration(map); + Assert.assertEquals(1, mc.getMap().size()); + Assert.assertEquals(value, mc.getString(key)); + } +} Propchange: commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestMapConfigurationRegression.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: commons/proper/configuration/branches/CONFIGURATION_1_X_MAINTENANCE/src/test/java/org/apache/commons/configuration/TestMapConfigurationRegression.java ------------------------------------------------------------------------------ svn:keywords = Id Author Date Revision