diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 4bcdd6e5b6..f790036336 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -54,6 +54,9 @@ Trunk (unreleased changes) BUG FIXES + HADOOP-8177. MBeans shouldn't try to register when it fails to create MBeanName. + (Devaraj K via umamahesh) + HADOOP-7900. LocalDirAllocator confChanged() accesses conf.get() twice (Ravi Gummadi via Uma Maheswara Rao G) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/MBeans.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/MBeans.java index 73c2109b30..8f2c01209c 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/MBeans.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/util/MBeans.java @@ -53,19 +53,21 @@ static public ObjectName register(String serviceName, String nameName, Object theMbean) { final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = getMBeanName(serviceName, nameName); - try { - mbs.registerMBean(theMbean, name); - LOG.debug("Registered "+ name); - return name; - } catch (InstanceAlreadyExistsException iaee) { - if (LOG.isTraceEnabled()) { - LOG.trace("Failed to register MBean \""+ name + "\"", iaee); - } else { - LOG.warn("Failed to register MBean \""+ name - + "\": Instance already exists."); + if (name != null) { + try { + mbs.registerMBean(theMbean, name); + LOG.debug("Registered " + name); + return name; + } catch (InstanceAlreadyExistsException iaee) { + if (LOG.isTraceEnabled()) { + LOG.trace("Failed to register MBean \"" + name + "\"", iaee); + } else { + LOG.warn("Failed to register MBean \"" + name + + "\": Instance already exists."); + } + } catch (Exception e) { + LOG.warn("Failed to register MBean \"" + name + "\"", e); } - } catch (Exception e) { - LOG.warn("Failed to register MBean \""+ name + "\"", e); } return null; }