Skip to content

Commit c7fd241

Browse files
committed
fix: 分支规则表达式修改#AI Commit#
1 parent d16ccba commit c7fd241

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

  • dss-orchestrator/orchestrators/dss-workflow/dss-flow-execution-server/src/main/scala/com/webank/wedatasphere/dss/flow/execution/entrance/utils

dss-orchestrator/orchestrators/dss-workflow/dss-flow-execution-server/src/main/scala/com/webank/wedatasphere/dss/flow/execution/entrance/utils/BranchExpressionUtils.scala

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,23 @@ object BranchExpressionUtils extends Logging {
8181
Option(raw).map(_.split("[\\r\\n;]+").toSeq).getOrElse(Seq.empty)
8282
.map(_.trim)
8383
.filter(_.nonEmpty)
84-
.flatMap { line =>
85-
val parts = line.split("=", 2).map(_.trim)
86-
if (parts.length == 2 && parts(0).nonEmpty && parts(1).nonEmpty) {
87-
Some(BranchRule(parts(0), parts(1)))
88-
} else None
84+
.flatMap(parseBranchRule)
85+
}
86+
87+
private def parseBranchRule(line: String): Option[BranchRule] = {
88+
val separatorIndex = Option(line).map(_.lastIndexOf('=')).getOrElse(-1)
89+
if (separatorIndex <= 0 || separatorIndex >= line.length - 1) {
90+
warn(s"Invalid branch rule syntax: $line")
91+
None
92+
} else {
93+
val condition = line.substring(0, separatorIndex).trim
94+
val targetName = line.substring(separatorIndex + 1).trim
95+
if (condition.nonEmpty && targetName.nonEmpty) Some(BranchRule(condition, targetName))
96+
else {
97+
warn(s"Invalid branch rule syntax: $line")
98+
None
8999
}
100+
}
90101
}
91102

92103
def isDefaultRule(rule: BranchRule): Boolean = DefaultRuleValues.contains(Option(rule.condition).map(_.trim.toLowerCase).getOrElse(""))
@@ -194,3 +205,4 @@ object BranchExpressionUtils extends Logging {
194205
}
195206
}
196207
}
208+

0 commit comments

Comments
 (0)