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:14:53 UTC
svn commit: r1359064 - in /db/derby/code/branches/10.9: ./
java/engine/org/apache/derby/iapi/util/DoubleProperties.java
Author: kahatlen
Date: Mon Jul 9 11:14:53 2012
New Revision: 1359064
URL: http://svn.apache.org/viewvc?rev=1359064&view=rev
Log:
DERBY-5830: Make DoubleProperties.propertyNames() thread-safe
Backported revision 1353852 from trunk.
Modified:
db/derby/code/branches/10.9/ (props changed)
db/derby/code/branches/10.9/java/engine/org/apache/derby/iapi/util/DoubleProperties.java
Propchange: db/derby/code/branches/10.9/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1353852
Modified: db/derby/code/branches/10.9/java/engine/org/apache/derby/iapi/util/DoubleProperties.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/engine/org/apache/derby/iapi/util/DoubleProperties.java?rev=1359064&r1=1359063&r2=1359064&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/engine/org/apache/derby/iapi/util/DoubleProperties.java (original)
+++ db/derby/code/branches/10.9/java/engine/org/apache/derby/iapi/util/DoubleProperties.java Mon Jul 9 11:14:53 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());
+ }
+ }
+ }
}