tkobayas opened a new issue, #6733: URL: https://github.com/apache/incubator-kie-drools/issues/6733
**Description:** `ListDataStore` uses `IdentityHashMap<T, DataHandle>` for internal storage (line 40). `IdentityHashMap` does not guarantee iteration order, so when `subscribe()` replays existing events to a new `DataProcessor` via `store.values().forEach(...)` (line 97), events are delivered in arbitrary order. This causes incorrect behavior for CEP sliding windows (`SlidingLengthWindow`, `SlidingTimeWindow`) when events are added to a `DataStore` before a subscriber is attached. The window keeps the "last N" events, but which N survive depends on the non-deterministic iteration order — producing flaky results. **Reproduction:** 1. Create a `DataStore<T>` via `DataSource.createStore()` 2. Add N events (N > window size) to the store 3. Build a `RuleUnit` with a sliding length window rule 4. Create a `RuleUnitInstance` and bind the `DataStore` (triggers subscribe() → replay) 5. `fireAllRules()` returns different counts across runs **Expected:** Events replayed in insertion order, consistent with how they'd behave if inserted after subscription. **Root cause:** `IdentityHashMap` provides identity-based keying (== instead of .equals()) — which is correct — but sacrifices insertion order. Java has no LinkedIdentityHashMap. **Possible fix:** Maintain a separate `ArrayList<DataHandle>` for ordered iteration alongside the `IdentityHashMap` for identity-based lookup, or use a `LinkedHashMap` with identity-based key wrappers. -- 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]
