在Drools LHS中绑定多个变量会引发NPE

时间:2012-03-14 22:49:35

标签: drools

我已搜索但无法找到为什么这个简单的代码会在Drools(核心5.2.1.Final和编译器5.2.0.Final)中失败。

rule "name"
no-loop true
when
    $offer: Offer(properties != null && properties.size() > 0, $properties : properties)
    $invalidProperty: ContextualizedOfferProperty(name == null || "".equals(name)) from $properties
then
...
end

我得到以下异常:

java.lang.NullPointerException
    at org.drools.reteoo.FromNode.<init>(FromNode.java:87)
    at org.drools.reteoo.builder.FromBuilder.build(FromBuilder.java:41)
    at org.drools.reteoo.builder.PatternBuilder.attachPattern(PatternBuilder.java:122)
    at org.drools.reteoo.builder.PatternBuilder.build(PatternBuilder.java:76)
    at org.drools.reteoo.builder.GroupElementBuilder$AndBuilder.build(GroupElementBuilder.java:126)
    at org.drools.reteoo.builder.GroupElementBuilder.build(GroupElementBuilder.java:73)
    at org.drools.reteoo.builder.ReteooRuleBuilder.addSubRule(ReteooRuleBuilder.java:152)
    at org.drools.reteoo.builder.ReteooRuleBuilder.addRule(ReteooRuleBuilder.java:123)
    at org.drools.reteoo.ReteooBuilder.addRule(ReteooBuilder.java:110)
    at org.drools.reteoo.ReteooRuleBase.addRule(ReteooRuleBase.java:419)
    at org.drools.common.AbstractRuleBase.addRule(AbstractRuleBase.java:814)
    at org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:555)
    at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:436)
    at org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:149

如果我删除第二个绑定,它会正确传递。我尝试了许多不同的简单绑定,如果我有两个绑定,它总是抛出,一个引用另一个......

基本上,我希望为每个具有至少一个属性的商品没有名称的ContextualizedOfferProperty触发规则。

有什么想法吗?

谢谢,

约翰

1 个答案:

答案 0 :(得分:1)

它看起来像一个bug。你试过5.3.1版吗?它修复了这样的几个编译问题。