Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-2621

NPE due to activation.getDeclarationValue( declId )

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.1.0.FINAL
    • Fix Version/s: 6.0.0.Alpha1
    • Component/s: drools-api
    • Labels:
      None
    • Estimated Difficulty:
      Low

      Description

      Trying to access the declarations and their values of an activation, as used during ActivationEvent logging:

      List<String> declIds = );
      for( String declId: activation.getDeclarationIDs( )

      { Object declVal = activation.getDeclarationValue( declId ); // ... }

      If, however, a fact is retracted, this code, when executed for an AfterActivationFiredEvent, throws a NPE when declId is a binding for a component of the retracted fact.

      The optimum solution would be to not get such useless bindings in the List<String> returned by getDeclarationIDs() which is in AgendaItem.java. I have added the if-statement. The following code is untested:

      public List<String> getDeclarationIDs() {
      Declaration[] declArray = this.getRule().getDeclarations();
      List<String> declarations = new ArrayList<String>();
      for( Declaration decl : declArray ) {
      // return only "sound" declaration IDs
      if( this.tuple.get( decl ).getObject() != null )

      { declarations.add( decl.getIdentifier() ); }

      }
      return Collections.unmodifiableList( declarations );
      }

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                tirelli Edson Tirelli
                Reporter:
                laune Wolfgang Laun
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: