当configList为null时,AND逻辑不应继续进行,但是我收到此错误-“数组索引超出范围” 。
以下是规则:
rule "testRule"
when
config : Config( configList != null && !configList.empty && configList[0].attribute != null )
then
// logic
end
答案 0 :(得分:0)
由于Drools执行规则条件的方式,因此不能保证短路逻辑运算符。在某些情况下,它们可以工作,但在其他情况下,则不能。
作为一种解决方法,您可以将单个模式分成两个:
rule "testRule"
when
config : Config( $configList: configList != null, configList.empty == false)
Attribute() from $configList.get(0)
then
// logic
end
我假设$configList
是Attribute
对象的列表。
希望有帮助,