!66 bugfix:ThreadLocalConnection 多数据源情况下可能存在连接未关闭问题

Merge pull request !66 from linan/v4-dev
This commit is contained in:
Looly 2019-08-22 20:58:25 +08:00 committed by Gitee
commit 4a247db4b7

View File

@ -46,9 +46,11 @@ public enum ThreadLocalConnection {
GroupedConnection groupedConnection = threadLocal.get();
if (null != groupedConnection) {
groupedConnection.close(ds);
if(groupedConnection.removeAble()){
threadLocal.remove();
}
}
}
/**
* 分组连接根据不同的分组获取对应的连接用于多数据源情况
@ -97,5 +99,13 @@ public enum ThreadLocalConnection {
}
return this;
}
/**
* 多数据源情况情况下判断是否能从上下文中删除
* @return
*/
public boolean removeAble(){
return connMap.size()==0;
}
}
}