!252 BUGFIX 修复Redis配置源哨兵模式的地址检查

Merge pull request !252 from hxinyu/dev_v2
This commit is contained in:
铂赛东 2023-10-28 14:08:10 +00:00 committed by Gitee
commit 76494d0ece
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 10 additions and 2 deletions

View File

@ -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"));
}