Skip to content

Commit 26e2e60

Browse files
committed
创建数据源失败后,清除缓存
1 parent 7315e8b commit 26e2e60

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

hsweb-web-datasource/src/main/java/org/hsweb/web/datasource/dynamic/DynamicDataSourceServiceImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public javax.sql.DataSource getDataSource(String id) {
6464
@PreDestroy
6565
public void destroyAll() throws Exception {
6666
cache.values().stream().map(CacheInfo::getDataSource).forEach(this::closeDataSource);
67+
cache.clear();
6768
}
6869

6970
protected void closeDataSource(javax.sql.CommonDataSource ds) {
@@ -156,6 +157,7 @@ protected javax.sql.DataSource createDataSource(DataSource dataSource) {
156157
success[0] = true;
157158
} catch (AtomikosSQLException e) {
158159
closeDataSource(dataSourceBean);
160+
cache.remove(dataSource.getId());
159161
}
160162
}).start();
161163
//初始化检测
@@ -165,6 +167,7 @@ protected javax.sql.DataSource createDataSource(DataSource dataSource) {
165167
if (!success[0]) {
166168
logger.error("初始化jdbc超时:{}", dataSourceBean);
167169
closeDataSource(dataSourceBean);
170+
cache.remove(dataSource.getId());
168171
}
169172
} catch (Exception e) {
170173

0 commit comments

Comments
 (0)