From 7cf9c1598401dc7b54d8d1ccedccc17ec3f33f3e Mon Sep 17 00:00:00 2001 From: ibaiyy <zranfly@qq.com> Date: 星期四, 23 五月 2024 21:49:24 +0800 Subject: [PATCH] 流程办理时校验是否是任务办理人【提交、委托、转办、终止、退回】 --- ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/factory/OssFactory.java | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/factory/OssFactory.java b/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/factory/OssFactory.java index cbda62a..d70270a 100644 --- a/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/factory/OssFactory.java +++ b/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/factory/OssFactory.java @@ -24,6 +24,7 @@ public class OssFactory { private static final Map<String, OssClient> CLIENT_CACHE = new ConcurrentHashMap<>(); + private static final ReentrantLock LOCK = new ReentrantLock(); /** * 鑾峰彇榛樿瀹炰緥 @@ -51,14 +52,16 @@ OssClient client = CLIENT_CACHE.get(key); // 瀹㈡埛绔笉瀛樺湪鎴栭厤缃笉鐩稿悓鍒欓噸鏂版瀯寤� if (client == null || !client.checkPropertiesSame(properties)) { - ReentrantLock lock = new ReentrantLock(); - lock.lock(); + LOCK.lock(); try { - CLIENT_CACHE.put(key, new OssClient(configKey, properties)); - log.info("鍒涘缓OSS瀹炰緥 key => {}", configKey); - return CLIENT_CACHE.get(key); + client = CLIENT_CACHE.get(key); + if (client == null || !client.checkPropertiesSame(properties)) { + CLIENT_CACHE.put(key, new OssClient(configKey, properties)); + log.info("鍒涘缓OSS瀹炰緥 key => {}", configKey); + return CLIENT_CACHE.get(key); + } } finally { - lock.unlock(); + LOCK.unlock(); } } return client; -- Gitblit v1.9.3