jsinovassin opened a new pull request, #891: URL: https://github.com/apache/unomi/pull/891
## Summary - Adapted backport of #879 to `unomi-3.0.x`. - The MVEL expression cache was a `ConcurrentHashMap` keyed by the raw script text, with no bound. Every distinct script a caller sends adds an entry, and this line also stores a REJECTED script under `INVALID_SCRIPT_MARKER`, so a caller whose scripts never pass the filter still grows the map. The public context endpoint evaluates caller-supplied conditions, so that growth is reachable with no credential. - The cache is now a size-bounded LRU keyed by a SHA-256 hash of the script. The bound defaults to 1000 and is overridable with `org.apache.unomi.scripting.mvel.expressions.cache.max.size`. ## Differences from master - **Only one of the two halves applies.** `TypeResolutionServiceImpl` does not exist on this line, and neither does the `LOGGED_RECURSION_CHAINS` set of `EventServiceImpl`, so the two diagnostic bounds the master commit adds have nothing to bound here. The title says what this change does rather than repeating the master one. - **The flow around the cache is this line's own.** `execute()` here caches a rejected script under a marker and looks the entry up twice. The change keeps that behaviour and bounds the map. Master reaches the same bound through the flow #877 left behind, where a rejected script is not stored at all. - The unit test asserts the bound and the key shape. It does not assert master's "rejected scripts are not stored", which is not this line's behaviour. ## Test plan - [ ] `MvelScriptExecutorTest` on this branch, CI. - [ ] `testExpressionCacheIsBounded` discriminates: with the cache reverted to an unbounded map, 50 distinct scripts leave 50 entries and the assertion fails. -- 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]
