diff --git a/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/core/EncryptorManager.java b/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/core/EncryptorManager.java index a6d3cf9c..2d795e07 100644 --- a/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/core/EncryptorManager.java +++ b/ruoyi-common/ruoyi-common-encrypt/src/main/java/org/dromara/common/encrypt/core/EncryptorManager.java @@ -17,7 +17,10 @@ import org.springframework.core.type.classreading.CachingMetadataReaderFactory; import org.springframework.util.ClassUtils; import java.lang.reflect.Field; -import java.util.*; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @@ -34,7 +37,7 @@ public class EncryptorManager { /** * 缓存加密器 */ - Map encryptorMap = new ConcurrentHashMap<>(); + Map encryptorMap = new ConcurrentHashMap<>(); /** * 类加密字段缓存 @@ -67,11 +70,12 @@ public class EncryptorManager { * @param encryptContext 加密执行者需要的相关配置参数 */ public IEncryptor registAndGetEncryptor(EncryptContext encryptContext) { - if (encryptorMap.containsKey(encryptContext)) { - return encryptorMap.get(encryptContext); + int key = encryptContext.hashCode(); + if (encryptorMap.containsKey(key)) { + return encryptorMap.get(key); } IEncryptor encryptor = ReflectUtil.newInstance(encryptContext.getAlgorithm().getClazz(), encryptContext); - encryptorMap.put(encryptContext, encryptor); + encryptorMap.put(key, encryptor); return encryptor; } @@ -81,7 +85,7 @@ public class EncryptorManager { * @param encryptContext 加密执行者需要的相关配置参数 */ public void removeEncryptor(EncryptContext encryptContext) { - this.encryptorMap.remove(encryptContext); + this.encryptorMap.remove(encryptContext.hashCode()); } /**