diff --git a/liteflow-rule-plugin/liteflow-rule-redis/src/main/java/com/yomahub/liteflow/parser/redis/RedisXmlELParser.java b/liteflow-rule-plugin/liteflow-rule-redis/src/main/java/com/yomahub/liteflow/parser/redis/RedisXmlELParser.java index 547b291c..756c8e72 100644 --- a/liteflow-rule-plugin/liteflow-rule-redis/src/main/java/com/yomahub/liteflow/parser/redis/RedisXmlELParser.java +++ b/liteflow-rule-plugin/liteflow-rule-redis/src/main/java/com/yomahub/liteflow/parser/redis/RedisXmlELParser.java @@ -40,13 +40,17 @@ public class RedisXmlELParser extends ClassXmlFlowELParser { try { RedisParserVO redisParserVO = null; + String configJson; if (MapUtil.isNotEmpty((liteflowConfig.getRuleSourceExtDataMap()))) { - redisParserVO = BeanUtil.toBean(liteflowConfig.getRuleSourceExtDataMap(), - RedisParserVO.class, CopyOptions.create()); - } - else if (StrUtil.isNotBlank(liteflowConfig.getRuleSourceExtData())) { - redisParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), RedisParserVO.class); + configJson = JsonUtil.toJsonString(liteflowConfig.getRuleSourceExtDataMap()); + }else if (StrUtil.isNotBlank(liteflowConfig.getRuleSourceExtData())) { + configJson = liteflowConfig.getRuleSourceExtData(); + }else{ + throw new RedisException(ERROR_COMMON_MSG); } + + redisParserVO = JsonUtil.parseObject(configJson, RedisParserVO.class); + if (Objects.isNull(redisParserVO)) { throw new RedisException(ERROR_COMMON_MSG); } diff --git a/liteflow-rule-plugin/liteflow-rule-redis/src/main/java/com/yomahub/liteflow/parser/redis/mode/RClient.java b/liteflow-rule-plugin/liteflow-rule-redis/src/main/java/com/yomahub/liteflow/parser/redis/mode/RClient.java index cfa4a1bf..535dcd64 100644 --- a/liteflow-rule-plugin/liteflow-rule-redis/src/main/java/com/yomahub/liteflow/parser/redis/mode/RClient.java +++ b/liteflow-rule-plugin/liteflow-rule-redis/src/main/java/com/yomahub/liteflow/parser/redis/mode/RClient.java @@ -37,7 +37,7 @@ public class RClient { * @return hashmap */ public Map getMap(String key) { - RMapCache mapCache = redissonClient.getMapCache(key); + RMapCache mapCache = redissonClient.getMapCache(key, StringCodec.INSTANCE); Set mapFieldSet = mapCache.keySet(); if (CollectionUtil.isEmpty(mapFieldSet)) { return map; @@ -69,7 +69,7 @@ public class RClient { * @return keySet */ public Set hkeys(String key) { - RMap map = redissonClient.getMap(key, new StringCodec()); + RMap map = redissonClient.getMap(key, StringCodec.INSTANCE); return map.readAllKeySet(); } @@ -81,7 +81,7 @@ public class RClient { * @return hash value */ public String hget(String key, String field) { - RMap map = redissonClient.getMap(key, new StringCodec()); + RMap map = redissonClient.getMap(key, StringCodec.INSTANCE); return map.get(field); } @@ -91,7 +91,7 @@ public class RClient { * @return shaDigest */ public String scriptLoad(String luaScript) { - RScript script = redissonClient.getScript(new StringCodec()); + RScript script = redissonClient.getScript(StringCodec.INSTANCE); return script.scriptLoad(luaScript); } @@ -102,7 +102,7 @@ public class RClient { * @return string */ public String evalSha(String shaDigest, String... args){ - RScript script = redissonClient.getScript(new StringCodec()); + RScript script = redissonClient.getScript(StringCodec.INSTANCE); return script.evalSha(RScript.Mode.READ_ONLY, shaDigest, RScript.ReturnType.VALUE, Arrays.asList(args)).toString(); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-redis-springboot/src/test/java/com/yomahub/liteflow/test/redis/RedisWithXmlELSubscribeSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-redis-springboot/src/test/java/com/yomahub/liteflow/test/redis/RedisWithXmlELSubscribeSpringbootTest.java index 523d13d0..a5388e8d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-redis-springboot/src/test/java/com/yomahub/liteflow/test/redis/RedisWithXmlELSubscribeSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-redis-springboot/src/test/java/com/yomahub/liteflow/test/redis/RedisWithXmlELSubscribeSpringbootTest.java @@ -18,6 +18,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.redisson.Redisson; import org.redisson.api.RMapCache; import org.redisson.api.RedissonClient; +import org.redisson.client.codec.StringCodec; import org.redisson.config.Config; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; @@ -60,8 +61,8 @@ public class RedisWithXmlELSubscribeSpringbootTest extends BaseTest { Config config = new Config(); config.useSingleServer().setAddress("redis://127.0.0.1:6379").setDatabase(1); redissonClient = Redisson.create(config); - RMapCache chainKey = redissonClient.getMapCache("testChainKey"); - RMapCache scriptKey = redissonClient.getMapCache("testScriptKey"); + RMapCache chainKey = redissonClient.getMapCache("testChainKey", StringCodec.INSTANCE); + RMapCache scriptKey = redissonClient.getMapCache("testScriptKey", StringCodec.INSTANCE); scriptKey.put("s1:script:脚本s1:groovy", "defaultContext.setData(\"test1\",\"hello s1\");"); scriptKey.put("s2:script:脚本s2:js", "defaultContext.setData(\"test2\",\"hello s2\");"); scriptKey.put("s3:script:脚本s3", "defaultContext.setData(\"test3\",\"hello s3\");"); @@ -183,8 +184,8 @@ public class RedisWithXmlELSubscribeSpringbootTest extends BaseTest { //redis内规则数据数据清空 public static void testCleanData() { if (ObjectUtil.isNotNull(redissonClient)) { - RMapCache chainKey = redissonClient.getMapCache("testChainKey"); - RMapCache scriptKey = redissonClient.getMapCache("testScriptKey"); + RMapCache chainKey = redissonClient.getMapCache("testChainKey", StringCodec.INSTANCE); + RMapCache scriptKey = redissonClient.getMapCache("testScriptKey", StringCodec.INSTANCE); for (String key : chainKey.keySet()) { chainKey.remove(key); }