You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2009/08/22 17:13:31 UTC

svn commit: r806862 - in /commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/BaseConfiguration.java src/test/org/apache/commons/configuration/TestBaseConfiguration.java xdocs/changes.xml

Author: oheger
Date: Sat Aug 22 15:13:31 2009
New Revision: 806862

URL: http://svn.apache.org/viewvc?rev=806862&view=rev
Log:
[CONFIGURATION-393] Special treatment of collection properties when cloning a BaseConfiguration.

Modified:
    commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java
    commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java
    commons/proper/configuration/trunk/xdocs/changes.xml

Modified: commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java?rev=806862&r1=806861&r2=806862&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java Sat Aug 22 15:13:31 2009
@@ -18,6 +18,7 @@
 package org.apache.commons.configuration;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -25,7 +26,7 @@
 import org.apache.commons.collections.map.LinkedMap;
 
 /**
- * Basic configuration classe. Stores the configuration data but does not
+ * Basic configuration class. Stores the configuration data but does not
  * provide any load or save functions. If you want to load your Configuration
  * from a file use PropertiesConfiguration or XmlConfiguration.
  *
@@ -45,7 +46,7 @@
  * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  * @author <a href="mailto:ksh@scand.com">Konstantin Shaposhnikov</a>
- * @author <a href="mailto:oliver.heger@t-online.de">Oliver Heger</a>
+ * @author Oliver Heger
  * @version $Id$
  */
 public class BaseConfiguration extends AbstractConfiguration implements Cloneable
@@ -165,6 +166,18 @@
         {
             BaseConfiguration copy = (BaseConfiguration) super.clone();
             copy.store = (Map) ConfigurationUtils.clone(store);
+
+            // Handle collections in the map; they have to be cloned, too
+            for (Iterator it = store.entrySet().iterator(); it.hasNext();)
+            {
+                Map.Entry e = (Map.Entry) it.next();
+                if (e.getValue() instanceof Collection)
+                {
+                    copy.store.put(e.getKey(), new ArrayList((Collection) e
+                            .getValue()));
+                }
+            }
+
             return copy;
         }
         catch (CloneNotSupportedException cex)

Modified: commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java?rev=806862&r1=806861&r2=806862&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java Sat Aug 22 15:13:31 2009
@@ -804,4 +804,18 @@
         assertEquals("Event listener was copied", 0, config2
                 .getConfigurationListeners().size());
     }
+
+    /**
+     * Tests the clone() method if a list property is involved.
+     */
+    public void testCloneListProperty()
+    {
+        final String key = "list";
+        config.addProperty(key, "value1");
+        config.addProperty(key, "value2");
+        BaseConfiguration config2 = (BaseConfiguration) config.clone();
+        config2.addProperty(key, "value3");
+        assertEquals("Wrong number of original properties", 2, config.getList(
+                key).size());
+    }
 }

Modified: commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/xdocs/changes.xml?rev=806862&r1=806861&r2=806862&view=diff
==============================================================================
--- commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ commons/proper/configuration/trunk/xdocs/changes.xml Sat Aug 22 15:13:31 2009
@@ -23,6 +23,10 @@
 
   <body>
     <release version="1.7" date="in SVN" description="">
+      <action dev="oheger" type="fix" issue="CONFIGURATION-393">
+        BaseConfiguration.clone() now also clones collections stored in the
+        internal map. This causes list properties to be handled correctly.
+      </action>
       <action dev="rgoers" type="fix" issue="CONFIGURATION-388">
         Attribute or element values will not be escaped when attribute or element splitting are disabled.
       </action>



Re: svn commit: r806862 - in /commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/BaseConfiguration.java src/test/org/apache/commons/configuration/TestBaseConfiguration.java xdocs/changes.xml

Posted by Ralph Goers <ra...@dslextreme.com>.
On Aug 23, 2009, at 10:45 AM, Oliver Heger wrote:
>>>
>>> @@ -45,7 +46,7 @@
>>> * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
>>> * @author <a href="mailto:hps@intermeta.de">Henning P.  
>>> Schmiedehausen</a>
>>> * @author <a href="mailto:ksh@scand.com">Konstantin Shaposhnikov</a>
>>> - * @author <a href="mailto:oliver.heger@t-online.de">Oliver  
>>> Heger</a>
>>> + * @author Oliver Heger
>> author tags should either be removed or made generic to reference  
>> the whole team (i.e. reference the developers page generated by  
>> maven).
>> Ralph
> There were already discussions about how to deal with author tags  
> without a clear outcome. In this special case I removed the email  
> address because it is no more valid anyway.
>
> Personally I prefer a generic team reference. However, without a  
> clear consensus I do not want to remove the other author tags.
>
I didn't mean to imply you should remove all author tags. But if you  
are going to modify one anyway it should be to a way that is  
acceptable. I don't think the format above is.

Ralph


Re: svn commit: r806862 - in /commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/BaseConfiguration.java src/test/org/apache/commons/configuration/TestBaseConfiguration.java xdocs/changes.xml

Posted by Oliver Heger <ol...@oliver-heger.de>.
Ralph Goers schrieb:
> 
> On Aug 22, 2009, at 8:13 AM, oheger@apache.org wrote:
> 
>> Author: oheger
>> Date: Sat Aug 22 15:13:31 2009
>> New Revision: 806862
>>
>> URL: http://svn.apache.org/viewvc?rev=806862&view=rev
>> Log:
>> [CONFIGURATION-393] Special treatment of collection properties when 
>> cloning a BaseConfiguration.
>>
>> Modified:
>>    
>> commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java 
>>
>>    
>> commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java 
>>
>>    commons/proper/configuration/trunk/xdocs/changes.xml
>>
>> Modified: 
>> commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java?rev=806862&r1=806861&r2=806862&view=diff 
>>
>> ============================================================================== 
>>
>> --- 
>> commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java 
>> (original)
>> +++ 
>> commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java 
>> Sat Aug 22 15:13:31 2009
>> @@ -18,6 +18,7 @@
>> package org.apache.commons.configuration;
>>
>> import java.util.ArrayList;
>> +import java.util.Collection;
>> import java.util.Iterator;
>> import java.util.List;
>> import java.util.Map;
>> @@ -25,7 +26,7 @@
>> import org.apache.commons.collections.map.LinkedMap;
>>
>> /**
>> - * Basic configuration classe. Stores the configuration data but does 
>> not
>> + * Basic configuration class. Stores the configuration data but does not
>>  * provide any load or save functions. If you want to load your 
>> Configuration
>>  * from a file use PropertiesConfiguration or XmlConfiguration.
>>  *
>> @@ -45,7 +46,7 @@
>>  * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
>>  * @author <a href="mailto:hps@intermeta.de">Henning P. 
>> Schmiedehausen</a>
>>  * @author <a href="mailto:ksh@scand.com">Konstantin Shaposhnikov</a>
>> - * @author <a href="mailto:oliver.heger@t-online.de">Oliver Heger</a>
>> + * @author Oliver Heger
> 
> author tags should either be removed or made generic to reference the 
> whole team (i.e. reference the developers page generated by maven).
> 
> Ralph
> 
There were already discussions about how to deal with author tags 
without a clear outcome. In this special case I removed the email 
address because it is no more valid anyway.

Personally I prefer a generic team reference. However, without a clear 
consensus I do not want to remove the other author tags.

Oliver

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r806862 - in /commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/BaseConfiguration.java src/test/org/apache/commons/configuration/TestBaseConfiguration.java xdocs/changes.xml

Posted by Ralph Goers <ra...@dslextreme.com>.
On Aug 22, 2009, at 8:13 AM, oheger@apache.org wrote:

> Author: oheger
> Date: Sat Aug 22 15:13:31 2009
> New Revision: 806862
>
> URL: http://svn.apache.org/viewvc?rev=806862&view=rev
> Log:
> [CONFIGURATION-393] Special treatment of collection properties when  
> cloning a BaseConfiguration.
>
> Modified:
>    commons/proper/configuration/trunk/src/java/org/apache/commons/ 
> configuration/BaseConfiguration.java
>    commons/proper/configuration/trunk/src/test/org/apache/commons/ 
> configuration/TestBaseConfiguration.java
>    commons/proper/configuration/trunk/xdocs/changes.xml
>
> Modified: commons/proper/configuration/trunk/src/java/org/apache/ 
> commons/configuration/BaseConfiguration.java
> URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java?rev=806862&r1=806861&r2=806862&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- commons/proper/configuration/trunk/src/java/org/apache/commons/ 
> configuration/BaseConfiguration.java (original)
> +++ commons/proper/configuration/trunk/src/java/org/apache/commons/ 
> configuration/BaseConfiguration.java Sat Aug 22 15:13:31 2009
> @@ -18,6 +18,7 @@
> package org.apache.commons.configuration;
>
> import java.util.ArrayList;
> +import java.util.Collection;
> import java.util.Iterator;
> import java.util.List;
> import java.util.Map;
> @@ -25,7 +26,7 @@
> import org.apache.commons.collections.map.LinkedMap;
>
> /**
> - * Basic configuration classe. Stores the configuration data but  
> does not
> + * Basic configuration class. Stores the configuration data but  
> does not
>  * provide any load or save functions. If you want to load your  
> Configuration
>  * from a file use PropertiesConfiguration or XmlConfiguration.
>  *
> @@ -45,7 +46,7 @@
>  * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
>  * @author <a href="mailto:hps@intermeta.de">Henning P.  
> Schmiedehausen</a>
>  * @author <a href="mailto:ksh@scand.com">Konstantin Shaposhnikov</a>
> - * @author <a href="mailto:oliver.heger@t-online.de">Oliver Heger</a>
> + * @author Oliver Heger

author tags should either be removed or made generic to reference the  
whole team (i.e. reference the developers page generated by maven).

Ralph

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org