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

Make innerDeclarations available during Accumulator init(...)

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 7.61.0.Final
    • core engine
    • None
    • NEW
    • NEW

      org.drools.core.spi.Accumulator instances are created within the KieBase, not within the KieSession. This means that multiple sessions from the same KieBase may be calling the accumulate(...) method on a shared accumulator from different threads. Therefore whatever initialization being performed needs to be thread-safe.

      The logical place for such code would be the init(...) method of the Accumulator interface. Unfortunately, we need access to innerDeclarations to be able to perform the accumulation quickly, and it only becomes available when this accumulate(...) method is called. Therefore, initialization of our accumulator can only happen when the accumulate(...) method is called, and therefore the initialization needs to be properly synchronized. This is difficult to do correctly, and we currently have to resort to double-checked locking, which is generally not advised.

      We propose that the init(...) method provides the innerDeclarations argument that accumulate(...) provides, so that the one-time initialization can be moved to the proper place in code.

              mfusco@redhat.com Mario Fusco
              lpetrovi@redhat.com Lukáš Petrovický (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: