Pre Merge pull request !448 from simple/多次创建创建OSS实例问题

This commit is contained in:
simple 2023-11-23 03:13:18 +00:00 committed by Gitee
commit 0163bcf328
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -49,9 +49,14 @@ public class OssFactory {
String key = properties.getTenantId() + ":" + configKey; String key = properties.getTenantId() + ":" + configKey;
OssClient client = CLIENT_CACHE.get(key); OssClient client = CLIENT_CACHE.get(key);
if (client == null) { if (client == null) {
CLIENT_CACHE.put(key, new OssClient(configKey, properties)); synchronized (CLIENT_CACHE) {
log.info("创建OSS实例 key => {}", configKey); client = CLIENT_CACHE.get(key);
return CLIENT_CACHE.get(key); if (client == null) {
CLIENT_CACHE.put(key, new OssClient(configKey, properties));
log.info("创建OSS实例 key => {}", configKey);
return CLIENT_CACHE.get(key);
}
}
} }
// 配置不相同则重新构建 // 配置不相同则重新构建
if (!client.checkPropertiesSame(properties)) { if (!client.checkPropertiesSame(properties)) {