Browse Source

HADOOP-6269. Fix threading issue with defaultResource in Configuration.
Contributed by Sreekanth Ramakrishnan


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@882831 13f79535-47bb-0310-9956-ffa450edef68

Christopher Douglas 15 years ago
parent
commit
09ec9c4ffc
2 changed files with 7 additions and 3 deletions
  1. 3 0
      CHANGES.txt
  2. 4 3
      src/java/org/apache/hadoop/conf/Configuration.java

+ 3 - 0
CHANGES.txt

@@ -1181,6 +1181,9 @@ Release 0.20.2 - Unreleased
     count at the start of each block in Hadoop archives. (Ben Slusky, Tom
     count at the start of each block in Hadoop archives. (Ben Slusky, Tom
     White, and Mahadev Konar via cdouglas)
     White, and Mahadev Konar via cdouglas)
 
 
+    HADOOP-6269. Fix threading issue with defaultResource in Configuration.
+    (Sreekanth Ramakrishnan via cdouglas)
+
 Release 0.20.1 - 2009-09-01
 Release 0.20.1 - 2009-09-01
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 4 - 3
src/java/org/apache/hadoop/conf/Configuration.java

@@ -44,6 +44,7 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.StringTokenizer;
 import java.util.WeakHashMap;
 import java.util.WeakHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.regex.Matcher;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.Pattern;
 
 
@@ -168,8 +169,8 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
    * List of default Resources. Resources are loaded in the order of the list 
    * List of default Resources. Resources are loaded in the order of the list 
    * entries
    * entries
    */
    */
-  private static final ArrayList<String> defaultResources = 
-    new ArrayList<String>();
+  private static final CopyOnWriteArrayList<String> defaultResources =
+    new CopyOnWriteArrayList<String>();
 
 
   private static final Map<ClassLoader, Map<String, Class<?>>>
   private static final Map<ClassLoader, Map<String, Class<?>>>
     CACHE_CLASSES = new WeakHashMap<ClassLoader, Map<String, Class<?>>>();
     CACHE_CLASSES = new WeakHashMap<ClassLoader, Map<String, Class<?>>>();
@@ -1685,7 +1686,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
     return sb.toString();
     return sb.toString();
   }
   }
 
 
-  private void toString(ArrayList resources, StringBuffer sb) {
+  private void toString(List resources, StringBuffer sb) {
     ListIterator i = resources.listIterator();
     ListIterator i = resources.listIterator();
     while (i.hasNext()) {
     while (i.hasNext()) {
       if (i.nextIndex() != 0) {
       if (i.nextIndex() != 0) {