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

NPE when removing a rule using a Java object with Drools annotations

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 5.5.1.Final
    • 5.5.0.Final
    • None
    • None
    • Hide

      Test case submitted as PR

      Show
      Test case submitted as PR

      • Drools 5.5.x still has Accessors : field readers and writers. They are created consistently (reader+writer) for declared types, but in case of non-declared types (java objects), only readers are created, and only when
        a field is involved in a constraint.
      • when a rule is added (dynamically) during an incremental construction process, the packagebuilder creates "redeclarations" (TypeDeclarations with
        NATURE == DECLARATION) of involved classes, in order to process annotations
        such as @Position or @Modifies.
      • if a rule triggers the removal/update of a rule in its own KB, AbstractRuleBase.executeQueuedActions() is called, which tries to rewire the accessors

      Problem: if the modified rule's package contains a TypeDeclaration for
      an annotated java object, only the reader will exist and the rewiring
      process will throw a NPE as it tries to rewire the writer.

      Possible solutions?
      a) make the rewiring process check that an accessor exists before trying to rewire it

      OR

      b) change AbstractRuleBase.executeQueuedActions() - the code seems to have
      been removed in 6.x (master)

      OR

      c) limit the rewiring to TypeDeclarations with Nature == DEFINITION

      OR

      d) always create the writer together with the reader

            mfusco@redhat.com Mario Fusco
            dsotty Davide Sottara (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: