!153 解决ruleSource多配置的时候逗号后面不可以有空格,会报错

Merge pull request !153 from Zero/feature/enhance_rule_source
This commit is contained in:
铂赛东 2023-01-13 06:13:08 +00:00 committed by Gitee
commit a450ea6e36
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 8 additions and 6 deletions

View File

@ -82,7 +82,8 @@ public class FlowExecutor {
//进行id生成器的初始化
IdGeneratorHolder.init();
if (StrUtil.isBlank(liteflowConfig.getRuleSource())) {
String ruleSource = liteflowConfig.getRuleSource();
if (StrUtil.isBlank(ruleSource)) {
//查看有没有Parser的SPI实现
//所有的Parser的SPI实现都是以custom形式放入的且只支持xml形式
ServiceLoader<ParserClassNameSpi> loader = ServiceLoader.load(ParserClassNameSpi.class);
@ -100,10 +101,11 @@ public class FlowExecutor {
//如果有前缀的则不需要再进行分割了说明是一个整体
//如果没有前缀说明是本地文件可能配置多个所以需要分割
List<String> sourceRulePathList;
if (ReUtil.contains(PREFIX_FORMAT_CONFIG_REGEX, liteflowConfig.getRuleSource())){
sourceRulePathList = ListUtil.toList(liteflowConfig.getRuleSource());
}else{
sourceRulePathList = ListUtil.toList(liteflowConfig.getRuleSource().split(",|;"));
if (ReUtil.contains(PREFIX_FORMAT_CONFIG_REGEX, ruleSource)) {
sourceRulePathList = ListUtil.toList(ruleSource);
} else {
String afterHandleRuleSource = ruleSource.replace(StrUtil.SPACE, StrUtil.EMPTY);
sourceRulePathList = ListUtil.toList(afterHandleRuleSource.split(",|;"));
}
FlowParser parser = null;

View File

@ -47,7 +47,7 @@ public class SubflowInDifferentConfigELDeclSpringbootTest extends BaseTest {
@Test(expected = MultipleParsersException.class)
public void testExplicitSubFlow2() {
LiteflowConfig config = context.getBean(LiteflowConfig.class);
config.setRuleSource("subflow/flow-main.xml,subflow/flow-sub1.xml,subflow/flow-sub2.yml");
config.setRuleSource("subflow/flow-main.xml, subflow/flow-sub1.xml,subflow/flow-sub2.yml");
flowExecutor.reloadRule();
}
}