PseudoClockDoubleNotTest DROOLS-479 #333

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

DROOLS-479

Richard Ambridge Add test ab427ed
@sotty sotty commented on the diff May 30, 2014
...mpiler/integrationtests/PseudoClockDoubleNotTest.java
+ public void run() {
+ ksession.fireUntilHalt();
+ System.out.println("FireThread stop");
+ }
+
+ }
+ Thread t = new Thread(new FireThread(ksession));
+ t.start();
+
+ try {
+ //Insert a smelly cheese. Template 1 should fire after 3 seconds passed
+ Cheese c = new Cheese("smelly");
+ ksession.insert(c);
+ if (doPseudo) {
+ SessionPseudoClock clock = ksession.getSessionClock();
+ clock.advanceTime(10, TimeUnit.SECONDS);
sotty
sotty May 30, 2014 Member

The problem is actually a race between the FireThread and the main thread. In Drools 6, the rule is evaluated and enabled when "fire" kicks in for the first time. The rule is then scheduled +3s later as soon as the time advances. In your case, when you advance the pseudo clock.
However, it may be the case that the main thread will advance the clock BEFORE the Fire Thread has activated the rule. If so, the rule will be considered the NEXT time you advance (again) the time. To make this test work, you'll have to make sure that the FireThread is awakened at least once before you move the pseudo clock.

Member

Reproduced in a slightly different way and fixed

@mariofusco mariofusco closed this Jul 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment