在线程流淌的高工作负载下流露异常

时间:2017-04-09 13:27:12

标签: java multithreading groovy drools

我有一个运行6.4.0.Final的Drools程序,在进行一些并发测试时,我们收到了以下异常。代码为每次触发规则创建一个新的kSession,然后处理它。两个线程无法访问同一个会话但是共享了kBase。

什么可能导致这种性质的例外?

代码是:

        KieBase kBase = ruleContainer.kBase
        if (kBase == null) {
            throw new RuleExecutionException("Failed to find compiled rules for package name")
        }

        // Set up the session
        KieSession kSession = kBase.newKieSession()

        ruleObjs.each { kSession.insert(it) }

        // Run the rules
        kSession.fireAllRules()
        kSession.dispose()

例外是:

java.lang.NullPointerException: null
    at org.drools.core.reteoo.NodeTypeEnums.isLeftTupleSource(NodeTypeEnums.java:84) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.phreak.SegmentUtilities.updateRiaAndTerminalMemory(SegmentUtilities.java:380) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.phreak.SegmentUtilities.updateRiaAndTerminalMemory(SegmentUtilities.java:381) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.phreak.SegmentUtilities.updateRiaAndTerminalMemory(SegmentUtilities.java:381) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.phreak.SegmentUtilities.createSegmentMemory(SegmentUtilities.java:171) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:166) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:63) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.reteoo.AlphaNode.assertObject(AlphaNode.java:134) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:494) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:384) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.reteoo.AlphaNode.assertObject(AlphaNode.java:134) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:494) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.reteoo.CompositeObjectSinkAdapter.teAssertObject(CompositeObjectSinkAdapter.java:384) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.reteoo.ObjectTypeNode.propagateAssert(ObjectTypeNode.java:300) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.phreak.PropagationEntry$Insert.execute(PropagationEntry.java:93) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.phreak.SynchronizedPropagationList.flush(SynchronizedPropagationList.java:78) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.phreak.SynchronizedPropagationList.flush(SynchronizedPropagationList.java:73) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.flushPropagations(StatefulKnowledgeSessionImpl.java:2017) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1334) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1288) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1306) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1297) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1278) ~[drools-core-6.4.0.Final.jar:6.4.0.Final]
    at org.kie.api.runtime.rule.StatefulRuleSession$fireAllRules.call(Unknown Source) ~[na:na]

0 个答案:

没有答案