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

newInsert.outIdentifier/getValue.identifier don't refer via fact handle (as per doc.), get only original, not replacement, fact object instances

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Major
    • None
    • 6.3.0.Final, 6.5.0.Final
    • core engine, kie server
    • None
    • NEW
    • NEW

    Description

      The identifier passed to the KieCommands.newInsert method's outIdentifier parameter and to the ExecutionResults.getValue method's identifier parameter doesn't actually refer to the fact object via the fact handle as described in the documentation of InsertObjectCommand).

      The documentation says:

      11.2.2. InsertObjectCommand
      ...
      outIdentifier Id to identify the FactHandle created in the object insertion and added to the execution results

      Although the Drools code in method InsertObjectCommand.execute does map the given identifier both to the original object and to the fact handle, the code in method ExecutionResultImpl.getValue retrieves the original object instead of retrieving the object currently associated with the fact handle.

      This means that if the original fact object instance is replaced with a different instance (e.g., with update(kcontext.getKieRuntime().getFactHandle($oldObj), newObj); in the rules), then ExecutionResults.getValue will return the original fact object, not the current value of the fact object (the object instance currently associated with the fact handle created in the newInsert call).

      That in turn means that immutable fact object instances cannot be used with ExecutionResults.getValue.

      (It's not 100% clear that it's the code that is wrong (relative to the documentation) rather than it being documentation that's wrong (relative to the code). However, the behavior described by the documentation seems more useful than the behavior exhibited by the code.)

      Attachments

        Activity

          People

            mmortari@redhat.com Matteo Mortari
            dsbos Daniel Barclay (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: