diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index b3c91a8dbb4..58e6e0ad582 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -136,6 +136,9 @@ Release 2.4.0 - UNRELEASED HADOOP-10228. FsPermission#fromShort() should cache FsAction.values(). (Haohui Mai via cnauroth) + HADOOP-10143 replace WritableFactories's hashmap with ConcurrentHashMap + (Liang Xie via stack) + BUG FIXES HADOOP-9964. Fix deadlocks in TestHttpServer by synchronize diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/WritableFactories.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/WritableFactories.java index 49bd0b914ef..a8fdbfe98df 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/WritableFactories.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/WritableFactories.java @@ -22,25 +22,26 @@ import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.*; import org.apache.hadoop.util.ReflectionUtils; -import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; /** Factories for non-public writables. Defining a factory permits {@link * ObjectWritable} to be able to construct instances of non-public classes. */ @InterfaceAudience.Public @InterfaceStability.Stable public class WritableFactories { - private static final HashMap CLASS_TO_FACTORY = - new HashMap(); + private static final Map CLASS_TO_FACTORY = + new ConcurrentHashMap(); private WritableFactories() {} // singleton /** Define a factory for a class. */ - public static synchronized void setFactory(Class c, WritableFactory factory) { + public static void setFactory(Class c, WritableFactory factory) { CLASS_TO_FACTORY.put(c, factory); } /** Define a factory for a class. */ - public static synchronized WritableFactory getFactory(Class c) { + public static WritableFactory getFactory(Class c) { return CLASS_TO_FACTORY.get(c); }