[
https://issues.jboss.org/browse/DROOLS-4305?page=com.atlassian.jira.plugi...
]
Benoit Proulx updated DROOLS-4305:
----------------------------------
Steps to Reproduce:
*Create a fact file*
{code:java}
public class TestFact {
private String testString;
public String getTestString() {return testString;}
public void setTestString(String testString) {this.testString = testString;}
}
{code}
*Create a test.drl file*
{code}
when
$test : TestFact(testString == "input")
then
$test.setTestString("output");
update($test);
{code}
*Create a Listener*
{code:java}
public class TestRuntimeListener implements
org.kie.api.event.rule.RuleRuntimeEventListener {
@Override public void objectDeleted(final ObjectDeletedEvent event) {}
@Override public void objectInserted(final ObjectInsertedEvent event) {}
@Override public void objectUpdated(final ObjectUpdatedEvent event) {
System.out.println("Old and New are the same? " + event.getOldObject() ==
event.getObject());
}
}
{code}
*Execute*
{code:java}
org.kie.api.runtime.KieSession kSession = _[Initialize KieSession]_
kSession.addEventListener(new TestRuntimeListener());
TestFact fact = new TestFact;
fact.setString("input");
kSession.insert(fact);
kSession.fireAllRules();
{code}
The console should show "Old and New are the same? true" indicating that both
getOldObject() and getObject() are of the same reference.
was:
*Create a fact file*
{code:java}
public class TestFact {
private String testString;
public String getTestString() {return testString;}
public void setTestString(String testString) {this.testString = testString;}
}
{code}
*Create a test.drl file*
{code}
when
$test : TestFact(testString == "input")
then
$test.setTestString("output");
update($test);
{code}
*Create a Listener*
{code:java}
public class TestRuntimeListener implements
org.kie.api.event.rule.RuleRuntimeEventListener {
@Override public void objectDeleted(final ObjectDeletedEvent event) {}
@Override public void objectInserted(final ObjectInsertedEvent event) {}
@Override public void objectUpdated(final ObjectUpdatedEvent event) {
System.out.println("Old and New are the same? " + event.getOldObject() ==
event.getObject());
}
}
{code}
Execute
{code:java}
org.kie.api.runtime.KieSession kSession = [Initialize KieSession]
kSession.addEventListener(new TestRuntimeListener());
TestFact fact = new TestFact;
fact.setString("input");
kSession.insert(fact);
kSession.fireAllRules();
{code}
The console should show "Old and New are the same? true" indicating that both
getOldObject() and getObject() are of the same reference.
getOldObject() of ObjectUpdatedEvent is returning same value as
getObject()
---------------------------------------------------------------------------
Key: DROOLS-4305
URL:
https://issues.jboss.org/browse/DROOLS-4305
Project: Drools
Issue Type: Bug
Components: core engine
Affects Versions: 7.16.0.Final
Environment: Windows 10 Version 1803 (OS Build 17134.829)
Eclipse 2018-12 (4.10.0)
jdk1.8.0_171
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T15:39:06-04:00)
spring-boot-starter-parent 2.1.2.RELEASE
Reporter: Benoit Proulx
Assignee: Mario Fusco
Priority: Optional
We have built a logger file for our rules that implements
org.kie.api.event.rule.RuleRuntimeEventListener.
Whenever the objectUpdated(ObjectUpdatedEvent) method is called, the ObjectUpdatedEvent
contains the values of both the old Object and new object (or getOldObject() and
getObject() )
However, it seems that getOldObject() is always returning the same value as getObject().
Having both values would be very helpful in debugging rules.
--
This message was sent by Atlassian Jira
(v7.12.1#712002)