You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2012/07/09 13:15:24 UTC

svn commit: r1359065 - in /db/derby/code/branches/10.8: ./ java/client/org/apache/derby/client/net/NetCursor.java java/engine/org/apache/derby/iapi/util/DoubleProperties.java

Author: kahatlen
Date: Mon Jul  9 11:15:24 2012
New Revision: 1359065

URL: http://svn.apache.org/viewvc?rev=1359065&view=rev
Log:
DERBY-5830: Make DoubleProperties.propertyNames() thread-safe

Backported revision 1353852 from trunk.

Modified:
    db/derby/code/branches/10.8/   (props changed)
    db/derby/code/branches/10.8/java/client/org/apache/derby/client/net/NetCursor.java   (props changed)
    db/derby/code/branches/10.8/java/engine/org/apache/derby/iapi/util/DoubleProperties.java

Propchange: db/derby/code/branches/10.8/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1353852

Propchange: db/derby/code/branches/10.8/java/client/org/apache/derby/client/net/NetCursor.java
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCursor.java:r1353852

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/iapi/util/DoubleProperties.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/iapi/util/DoubleProperties.java?rev=1359065&r1=1359064&r2=1359065&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/iapi/util/DoubleProperties.java (original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/iapi/util/DoubleProperties.java Mon Jul  9 11:15:24 2012
@@ -21,8 +21,10 @@
 
 package org.apache.derby.iapi.util;
 
-import java.util.Properties;
+import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Properties;
 
 /**
 	A properties object that links two independent
@@ -31,7 +33,7 @@ import java.util.Enumeration;
 	second. But any put() calls are always made directly to
 	the write object.
 
-    Only the put(), keys() and getProperty() methods are supported
+    Only the put(), propertyNames() and getProperty() methods are supported
 	by this class.
 */
 
@@ -60,23 +62,21 @@ public final class DoubleProperties exte
 	}
 
 	public Enumeration propertyNames() {
-
-		Properties p = new Properties();
-
-		if (write != null) {
-
-			for (Enumeration e = write.propertyNames(); e.hasMoreElements(); ) {
-				String key = (String) e.nextElement();
-				p.put(key, write.getProperty(key));
-			}
-		}
-
-		if (read != null) {
-			for (Enumeration e = read.propertyNames(); e.hasMoreElements(); ) {
-				String key = (String) e.nextElement();
-				p.put(key, read.getProperty(key));
-			}
-		}
-		return p.keys();
+        HashSet names = new HashSet();
+        addAllNames(write, names);
+        addAllNames(read, names);
+        return Collections.enumeration(names);
 	}
+
+    /**
+     * Add all property names in the Properties object {@code src} to the
+     * HashSet {@code dest}.
+     */
+    private static void addAllNames(Properties src, HashSet dest) {
+        if (src != null) {
+            for (Enumeration e = src.propertyNames(); e.hasMoreElements(); ) {
+                dest.add(e.nextElement());
+            }
+        }
+    }
 }