You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "tkobayas (via GitHub)" <gi...@apache.org> on 2026/08/26 08:04:20 UTC

[I] [incubator-kie-6235] RuleUnit DSL does not apply RuleConfig clock type to session [incubator-kie]

tkobayas opened a new issue, #6911:
URL: https://github.com/apache/incubator-kie/issues/6911

   ## Problem
   
   When creating a `RuleUnitInstance` from a `RuleUnitDefinition` (Java DSL) with a `RuleConfig` that sets `ClockType.PSEUDO`, the pseudo clock is not applied. The session still uses the default `JDKTimerService` (realtime clock), causing `unitInstance.getClock()` to fail with a `ClassCastException` when cast to `SessionPseudoClock`.
   
   ## Root Cause
   
   In `RuleUnitProviderForDSL.ModelRuleUnit.internalCreateInstance()`, the `RuleUnitExecutorImpl` is created **before** the `RuleConfig` clock type can be merged into the session configuration:
   
   ```java
   public RuleUnitInstance<T> internalCreateInstance(T data, RuleConfig ruleConfig) {
       ReteEvaluator reteEvaluator = new RuleUnitExecutorImpl(ruleBase); // uses default REALTIME clock
       return new DSLRuleUnitInstance<>(this, data, reteEvaluator, unitGlobalsResolver, ruleConfig);
   }
   ```
   
   The DRL-based RuleUnit path handles this via `RuleConfigImpl.mergeSessionConfiguration()` which is called before the executor is created. The DSL path should do the same.
   
   ## Expected Behavior
   
   ```java
   RuleConfig ruleConfig = RuleUnitProvider.get().newRuleConfig();
   ruleConfig.setClockType(ClockType.PSEUDO);
   
   try (RuleUnitInstance<MyUnit> unitInstance = RuleUnitProvider.get().createRuleUnitInstance(unit, ruleConfig)) {
       SessionPseudoClock clock = unitInstance.getClock(); // should work
       clock.advanceTime(40L, TimeUnit.MINUTES);
       unitInstance.fire(); // timer rules should fire after advancing
   }
   ```
   
   ## Actual Behavior
   
   ```
   java.lang.ClassCastException: class org.drools.core.time.impl.JDKTimerService cannot be cast to class org.kie.api.time.SessionPseudoClock
   ```
   
   ## Context
   
   Discovered while implementing rule attribute support for RuleUnit DSL ([incubator-kie#6235](https://github.com/apache/incubator-kie/issues/6235)). The `timer` attribute is supported in the DSL, but cannot be fully tested with pseudo clock due to this issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] RuleUnit DSL does not apply RuleConfig clock type to session [incubator-kie]

Posted by "tkobayas (via GitHub)" <gi...@apache.org>.
tkobayas closed issue #6911: RuleUnit DSL does not apply RuleConfig clock type to session
URL: https://github.com/apache/incubator-kie/issues/6911


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org