From 6c65aa2ad5b8e525854a0512da602af21bebd4bf Mon Sep 17 00:00:00 2001 From: houxinyu Date: Sat, 28 Oct 2023 21:04:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dredis=E5=93=A8=E5=85=B5?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/parser/redis/RedisXmlELParser.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 756c8e72..1de16453 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.parser.redis; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.text.StrFormatter; import cn.hutool.core.util.ObjectUtil; @@ -9,6 +10,7 @@ import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.core.FlowInitHook; import com.yomahub.liteflow.parser.el.ClassXmlFlowELParser; import com.yomahub.liteflow.parser.redis.exception.RedisException; +import com.yomahub.liteflow.parser.redis.mode.RedisMode; import com.yomahub.liteflow.parser.redis.mode.polling.RedisParserPollingMode; import com.yomahub.liteflow.parser.redis.mode.subscribe.RedisParserSubscribeMode; import com.yomahub.liteflow.parser.redis.mode.RedisParserHelper; @@ -97,12 +99,18 @@ public class RedisXmlELParser extends ClassXmlFlowELParser { } private void checkParserVO(RedisParserVO redisParserVO) { - if (StrUtil.isBlank(redisParserVO.getHost())) { + if (redisParserVO.getRedisMode().equals(RedisMode.SINGLE) && StrUtil.isBlank(redisParserVO.getHost())) { throw new RedisException(StrFormatter.format(ERROR_MSG_PATTERN, "host")); } - if (ObjectUtil.isNull(redisParserVO.getPort())) { + if (redisParserVO.getRedisMode().equals(RedisMode.SINGLE) && ObjectUtil.isNull(redisParserVO.getPort())) { throw new RedisException(StrFormatter.format(ERROR_MSG_PATTERN, "port")); } + if (redisParserVO.getRedisMode().equals(RedisMode.SENTINEL) && StrUtil.isBlank(redisParserVO.getMasterName())) { + throw new RedisException(StrFormatter.format(ERROR_MSG_PATTERN, "master name")); + } + if (redisParserVO.getRedisMode().equals(RedisMode.SENTINEL) && CollectionUtil.isEmpty(redisParserVO.getSentinelAddress())) { + throw new RedisException(StrFormatter.format(ERROR_MSG_PATTERN, "sentinel address list")); + } if (ObjectUtil.isNull(redisParserVO.getChainDataBase())) { throw new RedisException(StrFormatter.format(ERROR_MSG_PATTERN, "chainDataBase")); }