PDGGK opened a new pull request, #7287:
URL: https://github.com/apache/incubator-kie/pull/7287

   **Thank you for submitting this pull request**
   
   **NOTE!:** Double-check the target branch for this PR.
   The default is `main`.
   
   **Issue**:
   * https://github.com/apache/incubator-kie/issues/6938
   
   A session declared as stateless in the kmodule cannot be taken from a 
container sessions pool. `KieContainer.newStatelessKieSession("s")` works, but 
`kieContainer.newKieSessionsPool(n).newStatelessKieSession("s")` throws `Trying 
to create a stateful KieSession from a stateless KieSessionModel: s`. The 
message is backwards: the caller asked for a stateless session.
   
   The pool builds its sessions through 
`KieContainerImpl.createKieSessionsPool`, which gets the KieBase from 
`getKieBaseFromKieSessionModel`. That helper was written for `newKieSession` 
and rejects every model of type `STATELESS`, without knowing whether the pool 
is building stateful or stateless sessions. The existing pool tests did not hit 
this because they use the default stateful session model.
   
   The helper now takes the `stateless` flag and only rejects a `STATELESS` 
model on the stateful path, so `KieContainer.newKieSession(name)` keeps its 
check. A stateless pool keeps accepting a stateful model, so 
`pool.newStatelessKieSession()` without a name behaves as before.
   
   I reproduced the report with the released 10.2.0 jars and with 999-SNAPSHOT 
built from `main`, using a small program that declares one `STATELESS` session 
in a programmatic kmodule. The direct container call fires the rule, and the 
pool call throws the exception above. With the change, both calls fire the rule.
   
   `SessionsPoolTest#testStatelessKieSessionsPoolWithStatelessKieSessionModel` 
builds the kmodule with `KieSessionTestConfiguration.STATELESS_REALTIME` and 
executes the named stateless session from the pool twice. Without the change 
both parameterizations fail with the exception above. All 128 tests in 
`org.drools.mvel.integrationtests.session` and the 5 `drools-compiler` unit 
tests pass, and `install` of the two modules with enforcer and checkstyle 
enabled succeeds. I ran this on Java 17 only.
   
   Not changed: `pool.newStatelessKieSession()` without a name still looks up 
the default stateful session model, so a kmodule that only has a default 
stateless session still cannot use that overload. Changing that lookup would 
change which session model existing users get, so I left it out.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to