Skip to content

Commit

Permalink
Merge pull request alibaba#791 from yakolee/master
Browse files Browse the repository at this point in the history
  • Loading branch information
yakolee committed Feb 6, 2015
2 parents 715e2cb + 770504c commit b347ec6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
10 changes: 4 additions & 6 deletions src/main/java/com/alibaba/druid/pool/DruidDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -1394,12 +1394,10 @@ public void registerMbean() {
public Object run() {
ObjectName objectName = DruidDataSourceStatManager.addDataSource(DruidDataSource.this,
DruidDataSource.this.name);

if (objectName != null) {
DruidDataSource.this.setObjectName(objectName);
DruidDataSource.this.mbeanRegistered = true;
}


DruidDataSource.this.setObjectName(objectName);
DruidDataSource.this.mbeanRegistered = true;

return null;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,30 +127,21 @@ static IdentityHashMap<Object, ObjectName> getInstances0() {
}

public synchronized static ObjectName addDataSource(Object dataSource, String name) {
if (dataSource == null || name == null) {
return null;
}

final IdentityHashMap<Object, ObjectName> instances = getInstances();

synchronized (instances) {
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();

if (mbeanServer == null) {
return null;
}


if (instances.size() == 0) {
try {

ObjectName objectName = new ObjectName(MBEAN_NAME);
if (!mbeanServer.isRegistered(objectName)) {
mbeanServer.registerMBean(instance, objectName);
}
} catch (JMException ex) {
LOG.error("register mbean error", ex);
}

DruidStatService.registerMBean();
}

Expand Down

0 comments on commit b347ec6

Please sign in to comment.