[jboss-jira] [JBoss JIRA] (DROOLS-1541) newInsert.outIdentifier/getValue.identifier don't refer via fact handle (as per doc.), get only original, not replacement, fact object instances
Daniel B. (JIRA)
issues at jboss.org
Fri Apr 28 19:18:00 EDT 2017
Daniel B. created DROOLS-1541:
---------------------------------
Summary: newInsert.outIdentifier/getValue.identifier don't refer via fact handle (as per doc.), get only original, not replacement, fact object instances
Key: DROOLS-1541
URL: https://issues.jboss.org/browse/DROOLS-1541
Project: Drools
Issue Type: Bug
Affects Versions: 6.5.0.Final, 6.3.0.Final
Reporter: Daniel B.
Assignee: Edson Tirelli
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:
{quote}
11.2.2. InsertObjectCommand
...
outIdentifier Id to identify the FactHandle created in the object insertion and added to the execution results
{quote}
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.)
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
More information about the jboss-jira
mailing list