wuwen5 commented on code in PR #20197:
URL: https://github.com/apache/shardingsphere/pull/20197#discussion_r946451301
##########
shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/driver/DriverDataSourceCache.java:
##########
@@ -44,23 +43,17 @@ public DataSource get(final String url) throws SQLException
{
if (dataSourceMap.containsKey(url)) {
return dataSourceMap.get(url);
}
- DataSource dataSource;
+ return dataSourceMap.computeIfAbsent(url,
DriverDataSourceCache::createDataSource);
Review Comment:
Yep, this problem is that when the key present,Therefore, keeping the above
code can avoid this problem。
```
if (dataSourceMap.containsKey(url)) {
return dataSourceMap.get(url);
}
```
Similar solutions
https://github.com/mybatis/mybatis-3/pull/1934/commits/beee143f72b0c396591aa0c59739a1e64fd41867
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]