Browse Source

HADOOP-9504 MetricsDynamicMBeanBase has concurrency issues in createMBeanInfo. Contributed by Liang Xie and Jason Lowe.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1500339 13f79535-47bb-0310-9956-ffa450edef68
Matthew Foley 12 years ago
parent
commit
bec932ab3f

+ 3 - 0
CHANGES.txt

@@ -84,6 +84,9 @@ Release 1.2.1 - Unreleased
 
   BUG FIXES
 
+    HADOOP-9504 MetricsDynamicMBeanBase has concurrency issues in createMBeanInfo. 
+    (Liang Xie and Jason Lowe, via mattf)
+
     MAPREDUCE-5206. Ensure that a job doesn't get added to RetiredJobs
     multiple times in JobTracker. (acmurthy)
 

+ 2 - 2
src/core/org/apache/hadoop/metrics/util/MetricsDynamicMBeanBase.java

@@ -18,9 +18,9 @@
 package org.apache.hadoop.metrics.util;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import javax.management.Attribute;
 import javax.management.AttributeList;
@@ -70,6 +70,7 @@ public abstract class MetricsDynamicMBeanBase implements DynamicMBean {
   protected MetricsDynamicMBeanBase(final MetricsRegistry mr, final String aMBeanDescription) {
     metricsRegistry = mr;
     mbeanDescription = aMBeanDescription;
+    metricsRateAttributeMod = new ConcurrentHashMap<String, MetricsBase>();
     createMBeanInfo();
   }
   
@@ -79,7 +80,6 @@ public abstract class MetricsDynamicMBeanBase implements DynamicMBean {
   }
   
   private void createMBeanInfo() {
-    metricsRateAttributeMod = new HashMap<String, MetricsBase>();
     boolean needsMinMaxResetOperation = false;
     List<MBeanAttributeInfo> attributesInfo = new ArrayList<MBeanAttributeInfo>();
     MBeanOperationInfo[] operationsInfo = null;