commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r156639 - in jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/AbstractConfiguration.java src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java src/test/org/apache/commons/configuration/TestSubsetConfiguration.java xdocs/changes.xml
Date Wed, 09 Mar 2005 12:50:12 GMT
Author: ebourg
Date: Wed Mar  9 04:50:07 2005
New Revision: 156639

URL: http://svn.apache.org/viewcvs?view=rev&rev=156639
Log:
Fixed a ConcurrentModificationException thrown when calling clear() on a SubsetConfiguration
applied to a BaseConfiguration.

Modified:
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestSubsetConfiguration.java
    jakarta/commons/proper/configuration/trunk/xdocs/changes.xml

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java?view=diff&r1=156638&r2=156639
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java
Wed Mar  9 04:50:07 2005
@@ -261,7 +261,14 @@
         Iterator it = getKeys();
         while (it.hasNext())
         {
-            clearProperty((String) it.next());
+            String key = (String) it.next();
+            it.remove();
+
+            if (containsKey(key))
+            {
+                // workaround for Iterators that do not remove the property on calling remove()
+                clearProperty(key);
+            }
         }
     }
 

Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java?view=diff&r1=156638&r2=156639
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java
Wed Mar  9 04:50:07 2005
@@ -44,6 +44,8 @@
 {
     public final String DATABASE_DRIVER = "org.hsqldb.jdbcDriver";
     public final String DATABASE_URL = "jdbc:hsqldb:target/test-classes/testdb";
+    public final String DATABASE_USERNAME = "sa";
+    public final String DATABASE_PASSWORD = "";
 
     private static HsqlDB hsqlDB = null;
 
@@ -67,8 +69,8 @@
         BasicDataSource datasource = new BasicDataSource();
         datasource.setDriverClassName(DATABASE_DRIVER);
         datasource.setUrl(DATABASE_URL);
-        datasource.setUsername("sa");
-        datasource.setPassword("");
+        datasource.setUsername(DATABASE_USERNAME);
+        datasource.setPassword(DATABASE_PASSWORD);
 
         this.datasource = datasource;
         
@@ -118,7 +120,7 @@
 
     public void testGetPropertyDirectSingle()
     {
-        DatabaseConfiguration config = new DatabaseConfiguration(datasource, "configuration",
"key", "value");
+        Configuration config = new DatabaseConfiguration(datasource, "configuration", "key",
"value");
 
         assertEquals("property1", "value1", config.getProperty("key1"));
         assertEquals("property2", "value2", config.getProperty("key2"));
@@ -127,7 +129,7 @@
 
     public void testGetPropertyDirectMultiple()
     {
-        DatabaseConfiguration config = new DatabaseConfiguration(datasource, "configurations",
"name", "key", "value", "test");
+        Configuration config = new DatabaseConfiguration(datasource, "configurations", "name",
"key", "value", "test");
 
         assertEquals("property1", "value1", config.getProperty("key1"));
         assertEquals("property2", "value2", config.getProperty("key2"));
@@ -136,7 +138,7 @@
 
     public void testClearPropertySingle()
     {
-        DatabaseConfiguration config = new DatabaseConfiguration(datasource, "configuration",
"key", "value");
+        Configuration config = new DatabaseConfiguration(datasource, "configuration", "key",
"value");
         config.clearProperty("key");
 
         assertFalse("property not cleared", config.containsKey("key"));
@@ -144,7 +146,7 @@
 
     public void testClearPropertyMultiple()
     {
-        DatabaseConfiguration config = new DatabaseConfiguration(datasource, "configurations",
"name", "key", "value", "test");
+        Configuration config = new DatabaseConfiguration(datasource, "configurations", "name",
"key", "value", "test");
         config.clearProperty("key");
 
         assertFalse("property not cleared", config.containsKey("key"));
@@ -152,7 +154,7 @@
 
     public void testClearSingle()
     {
-        DatabaseConfiguration config = new DatabaseConfiguration(datasource, "configuration",
"key", "value");
+        Configuration config = new DatabaseConfiguration(datasource, "configuration", "key",
"value");
         config.clear();
 
         assertTrue("configuration is not cleared", config.isEmpty());
@@ -160,7 +162,7 @@
 
     public void testClearMultiple()
     {
-        DatabaseConfiguration config = new DatabaseConfiguration(datasource, "configurations",
"name", "key", "value", "test");
+        Configuration config = new DatabaseConfiguration(datasource, "configurations", "name",
"key", "value", "test");
         config.clear();
 
         assertTrue("configuration is not cleared", config.isEmpty());
@@ -168,7 +170,7 @@
 
     public void testGetKeysSingle()
     {
-        DatabaseConfiguration config = new DatabaseConfiguration(datasource, "configuration",
"key", "value");
+        Configuration config = new DatabaseConfiguration(datasource, "configuration", "key",
"value");
         Iterator it = config.getKeys();
 
         assertEquals("1st key", "key1", it.next());
@@ -177,7 +179,7 @@
 
     public void testGetKeysMultiple()
     {
-        DatabaseConfiguration config = new DatabaseConfiguration(datasource, "configurations",
"name", "key", "value", "test");
+        Configuration config = new DatabaseConfiguration(datasource, "configurations", "name",
"key", "value", "test");
         Iterator it = config.getKeys();
 
         assertEquals("1st key", "key1", it.next());
@@ -186,48 +188,59 @@
 
     public void testContainsKeySingle()
     {
-        DatabaseConfiguration config = new DatabaseConfiguration(datasource, "configuration",
"key", "value");
+        Configuration config = new DatabaseConfiguration(datasource, "configuration", "key",
"value");
         assertTrue("missing key1", config.containsKey("key1"));
         assertTrue("missing key2", config.containsKey("key2"));
     }
 
     public void testContainsKeyMultiple()
     {
-        DatabaseConfiguration config = new DatabaseConfiguration(datasource, "configurations",
"name", "key", "value", "test");
+        Configuration config = new DatabaseConfiguration(datasource, "configurations", "name",
"key", "value", "test");
         assertTrue("missing key1", config.containsKey("key1"));
         assertTrue("missing key2", config.containsKey("key2"));
     }
 
     public void testIsEmptySingle()
     {
-        DatabaseConfiguration config1 = new DatabaseConfiguration(datasource, "configuration",
"key", "value");
+        Configuration config1 = new DatabaseConfiguration(datasource, "configuration", "key",
"value");
         assertFalse("The configuration is empty", config1.isEmpty());
     }
 
     public void testIsEmptyMultiple()
     {
-        DatabaseConfiguration config1 = new DatabaseConfiguration(datasource, "configurations",
"name", "key", "value", "test");
+        Configuration config1 = new DatabaseConfiguration(datasource, "configurations", "name",
"key", "value", "test");
         assertFalse("The configuration named 'test' is empty", config1.isEmpty());
 
-        DatabaseConfiguration config2 = new DatabaseConfiguration(datasource, "configurations",
"name", "key", "value", "testIsEmpty");
+        Configuration config2 = new DatabaseConfiguration(datasource, "configurations", "name",
"key", "value", "testIsEmpty");
         assertTrue("The configuration named 'testIsEmpty' is not empty", config2.isEmpty());
     }
     
     public void testGetList()
     {
-        DatabaseConfiguration config1 = new DatabaseConfiguration(datasource, "configurationList",
"key", "value");
+        Configuration config1 = new DatabaseConfiguration(datasource, "configurationList",
"key", "value");
         List list = config1.getList("key3");
         assertEquals(3,list.size());
     }    
     
     public void testGetKeys()
     {
-        DatabaseConfiguration config1 = new DatabaseConfiguration(datasource, "configurationList",
"key", "value");
+        Configuration config1 = new DatabaseConfiguration(datasource, "configurationList",
"key", "value");
         Iterator i = config1.getKeys();
         assertTrue(i.hasNext());
         Object key = i.next();
         assertEquals("key3",key.toString());
         assertFalse(i.hasNext());
-    }     
+    }
+
+    public void testClearSubset()
+    {
+        Configuration config = new DatabaseConfiguration(datasource, "configuration", "key",
"value");
+
+        Configuration subset = config.subset("key1");
+        subset.clear();
+
+        assertTrue("the subset is not empty", subset.isEmpty());
+        assertFalse("the parent configuration is empty", config.isEmpty());
+    }
 
 }

Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestSubsetConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestSubsetConfiguration.java?view=diff&r1=156638&r2=156639
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestSubsetConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestSubsetConfiguration.java
Wed Mar  9 04:50:07 2005
@@ -211,4 +211,17 @@
         }
         assertTrue(keys.isEmpty());
     }
+
+    public void testClear()
+    {
+        Configuration config = new BaseConfiguration();
+        config.setProperty("test.key1", "value1");
+        config.setProperty("testing.key2", "value1");
+
+        Configuration subset = config.subset("test");
+        subset.clear();
+
+        assertTrue("the subset is not empty", subset.isEmpty());
+        assertFalse("the parent configuration is empty", config.isEmpty());
+    }
 }

Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?view=diff&r1=156638&r2=156639
==============================================================================
--- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Wed Mar  9 04:50:07 2005
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--
-   Copyright 2004 The Apache Software Foundation
+   Copyright 2004-2005 The Apache Software Foundation
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -22,7 +22,14 @@
 
   <body>
 
-    <release version="1.1-rc2" date="in CVS">
+    <release version="1.1" date="in CVS">
+      <action dev="ebourg" type="update" issue="33925">
+        Fixed a ConcurrentModificationException thrown when calling clear()
+        on a SubsetConfiguration applied to a BaseConfiguration.
+      </action>
+    </release>
+
+    <release version="1.1-rc2" date="2005-03-06">
       <action dev="oheger" type="update" issue="33814">
         Updated documentation for FileConfiguration's load() methods. Fixed a
         problem in XMLConfiguration with the output of the save() method when
@@ -42,7 +49,7 @@
       </action>
     </release>
 
-    <release version="1.1-rc1" date="2004-02-13">
+    <release version="1.1-rc1" date="2005-02-13">
       <action dev="oheger" type="add" issue="33475">
         ConfigurationFactory now always configures digester to use the context
         classloader. This avoids problems in application server environments,
@@ -183,9 +190,6 @@
         AppletConfiguration, ServletConfiguration, ServletContextConfiguration,
         ServletRequestConfiguration, ServletFilterConfiguration.
       </action>
-    </release>
-
-    <release version="1.0.1-dev" date="in CVS">
     </release>
 
     <release version="1.0" date="2004-10-11">



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


Mime
View raw message