Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-4864

accumulate causes NullPointerException

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Blocker
    • None
    • 7.30.0.Final
    • None
    • 2019 Week 50-52 (from Dec 9)
    • Hide

      Object class:

      public class InstrumentStateEvent {
      
          private String instrument;
          private int state;
      
          public InstrumentStateEvent() {
          }
      
          public InstrumentStateEvent(String instrument, int state) {
              this.instrument = instrument;
              this.state = state;
          }
      
          public String getInstrument() {
              return instrument;
          }
      
          public void setInstrument(String instrument) {
              this.instrument = instrument;
          }
      
          public int getState() {
              return state;
          }
      
          public void setState(int state) {
              this.state = state;
          }
      }
      

      Rule that causes NullPointerException on removal:

      rule "instrument_state_event_rule"
          no-loop
      when
          $max : Integer() from accumulate(
                  InstrumentStateEvent( $p : state, instrument == "non_existing_instrument" ),
                  max( $p ))
      then
              // smth
      end
      

      Another rule with different accumulate syntax, which also causes the same exception:

      rule "alternative_instrument_state_event_rule"
          no-loop
      when
          accumulate(
                  InstrumentStateEvent( $p : state, instrument == "non_existing_instrument" );
                  $max : max( $p ))
      then
              // smth
      end
      
      Show
      Object class: public class InstrumentStateEvent { private String instrument; private int state; public InstrumentStateEvent() { } public InstrumentStateEvent( String instrument, int state) { this .instrument = instrument; this .state = state; } public String getInstrument() { return instrument; } public void setInstrument( String instrument) { this .instrument = instrument; } public int getState() { return state; } public void setState( int state) { this .state = state; } } Rule that causes NullPointerException on removal: rule "instrument_state_event_rule" no-loop when $max : Integer () from accumulate( InstrumentStateEvent( $p : state, instrument == "non_existing_instrument" ), max( $p )) then // smth end Another rule with different accumulate syntax, which also causes the same exception: rule "alternative_instrument_state_event_rule" no-loop when accumulate( InstrumentStateEvent( $p : state, instrument == "non_existing_instrument" ); $max : max( $p )) then // smth end
    • NEW
    • NEW

    Description

      NullPointerException is thrown in AddRemoveRule::iterateLeftTuple when removing a rule that contains accumulate with max function and a source pattern that matches no object.

      Caused by: java.lang.NullPointerException
      	at deployment.my-full-bundle.ear//org.drools.core.phreak.AddRemoveRule.iterateLeftTuple(AddRemoveRule.java:1040)
      	at deployment.my-full-bundle.ear//org.drools.core.phreak.AddRemoveRule.iterateLeftTuple(AddRemoveRule.java:1047)
      	at deployment.my-full-bundle.ear//org.drools.core.phreak.AddRemoveRule.iterateLeftTuple(AddRemoveRule.java:1053)
      	at deployment.my-full-bundle.ear//org.drools.core.phreak.AddRemoveRule.iterateLeftTuple(AddRemoveRule.java:1053)
      	at deployment.my-full-bundle.ear//org.drools.core.phreak.AddRemoveRule.visitChild(AddRemoveRule.java:969)
      	at deployment.my-full-bundle.ear//org.drools.core.phreak.AddRemoveRule.lambda$processLeftTuples$1(AddRemoveRule.java:927)
      	at deployment.my-full-bundle.ear//org.drools.core.common.DefaultFactHandle$SingleLinkedTuples.forEachLeftTuple(DefaultFactHandle.java:728)
      	at deployment.my-full-bundle.ear//org.drools.core.common.DefaultFactHandle.forEachLeftTuple(DefaultFactHandle.java:924)
      	at deployment.my-full-bundle.ear//org.drools.core.phreak.AddRemoveRule.processLeftTuples(AddRemoveRule.java:922)
      	at deployment.my-full-bundle.ear//org.drools.core.phreak.AddRemoveRule.removeRule(AddRemoveRule.java:178)
      	at deployment.my-full-bundle.ear//org.drools.core.reteoo.ReteooBuilder.removeTerminalNode(ReteooBuilder.java:191)
      	at deployment.my-full-bundle.ear//org.drools.core.reteoo.ReteooBuilder.removeRules(ReteooBuilder.java:177)
      	at deployment.my-full-bundle.ear//org.drools.core.impl.KnowledgeBaseImpl.removeObjectsGeneratedFromResource(KnowledgeBaseImpl.java:1735)
      	at deployment.my-full-bundle.ear//org.drools.compiler.builder.impl.KnowledgeBuilderImpl.removeObjectsGeneratedFromResource(KnowledgeBuilderImpl.java:2151)
      	at deployment.my-full-bundle.ear//org.drools.compiler.kie.builder.impl.KieBaseUpdater.removeResources(KieBaseUpdater.java:121)
      	at deployment.my-full-bundle.ear//org.drools.compiler.kie.builder.impl.KieBaseUpdater.run(KieBaseUpdater.java:66)
      	at deployment.my-full-bundle.ear//org.drools.core.impl.KnowledgeBaseImpl.enqueueModification(KnowledgeBaseImpl.java:745)
      	at deployment.my-full-bundle.ear//org.drools.compiler.kie.builder.impl.KieContainerImpl.update(KieContainerImpl.java:267)
      	at deployment.my-full-bundle.ear//org.drools.compiler.kie.builder.impl.KieContainerImpl.update(KieContainerImpl.java:237)
      	at deployment.my-full-bundle.ear//org.drools.compiler.kie.builder.impl.KieContainerImpl.updateToVersion(KieContainerImpl.java:195)
      	at deployment.my-full-bundle.ear.rules-comp-impl.jar//com.my.rules.RuleKnowledgeBase.removeRuleFromKnowledgeBase(RuleKnowledgeBase.java:481)
      

      Attachments

        Issue Links

          Activity

            People

              mfusco@redhat.com Mario Fusco
              vpriscan Vedran Prišćan (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: