mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for useGloalDataSourceStat
This commit is contained in:
@@ -473,13 +473,13 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
|
||||
if (isUseGloalDataSourceStat()) {
|
||||
dataSourceStat = JdbcDataSourceStat.getGlobal();
|
||||
if (dataSourceStat.getDbType() == null) {
|
||||
dataSourceStat.setDbType(this.getDbType());
|
||||
}
|
||||
if (dataSourceStat == null) {
|
||||
dataSourceStat = new JdbcDataSourceStat("Global", "Global", this.dbType);
|
||||
JdbcDataSourceStat.setGlobal(dataSourceStat);
|
||||
}
|
||||
if (dataSourceStat.getDbType() == null) {
|
||||
dataSourceStat.setDbType(this.getDbType());
|
||||
}
|
||||
} else {
|
||||
dataSourceStat = new JdbcDataSourceStat(this.name, this.jdbcUrl, this.dbType);
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ public class JdbcDataSourceStat implements JdbcDataSourceStatMBean {
|
||||
private final AtomicLong blobOpenCount = new AtomicLong();
|
||||
|
||||
private static JdbcDataSourceStat global = new JdbcDataSourceStat(
|
||||
"global",
|
||||
"global");
|
||||
"Global",
|
||||
"Global");
|
||||
|
||||
public static JdbcDataSourceStat getGlobal() {
|
||||
return global;
|
||||
|
||||
@@ -77,6 +77,7 @@ public class GlobalStatTest0 extends TestCase {
|
||||
String json = JSONUtils.toJSONString(JdbcStatManager.getInstance().getSqlList());
|
||||
List<Map<String, Object>> sqlList = (List<Map<String, Object>>) JSONUtils.parse(json);
|
||||
Map<String, Object> sqlInfo = sqlList.get(0);
|
||||
Assert.assertNotNull(sqlInfo);
|
||||
Assert.assertEquals(JdbcConstants.MOCK, sqlInfo.get("DbType"));
|
||||
Assert.assertEquals(2, sqlInfo.get("ExecuteCount"));
|
||||
Assert.assertEquals(2, sqlInfo.get("FetchRowCount"));
|
||||
|
||||
Reference in New Issue
Block a user