mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
bugfix ThreadLocalConnection 多数据源情况下可能存在连接未关闭
This commit is contained in:
@@ -46,9 +46,11 @@ public enum ThreadLocalConnection {
|
|||||||
GroupedConnection groupedConnection = threadLocal.get();
|
GroupedConnection groupedConnection = threadLocal.get();
|
||||||
if (null != groupedConnection) {
|
if (null != groupedConnection) {
|
||||||
groupedConnection.close(ds);
|
groupedConnection.close(ds);
|
||||||
|
if(groupedConnection.removeAble()){
|
||||||
threadLocal.remove();
|
threadLocal.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分组连接,根据不同的分组获取对应的连接,用于多数据源情况
|
* 分组连接,根据不同的分组获取对应的连接,用于多数据源情况
|
||||||
@@ -97,5 +99,13 @@ public enum ThreadLocalConnection {
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多数据源情况情况下判断是否能从上下文中删除
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean removeAble(){
|
||||||
|
return connMap.size()==0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user