jakartaee / expression-language

Jakarta Expression Language
https://eclipse.org/ee4j/el
Other
70 stars 50 forks source link

bugfix(BeanELResolver): using WeakReferences instead of SoftReference… #219

Closed lprimak closed 2 months ago

lprimak commented 4 months ago

…s for caching to avoid unnecessary memory pressure

Possibly fixes #214 fixes #218 Possibly supersedes #215

lprimak commented 3 months ago

Thinking more about this, I am not sure this is going to cache things correctly. BeanProperties is now a WeakReference so it will most likely be cleaned out on every GC.

@markt-asf What do you think? I am not sure that clean() method can be avoided. Or maybe introduce a 'Real' cache via a library of some kind?

lprimak commented 3 months ago

Thought about this for 2-3 hours, made a few examples, and I came to the conclusion (again) that there is no automatic way to "scope" the cache correctly. Either it will cause unnecessary memory pressure (SoftReference) or can hang on too long (WeakReference or time/LRU-based cache)

The only way to correctly invalidate this cache is to have a clearProperties() method as in #215

lprimak commented 3 months ago

I have made this PR draft, as it probably should be closed in favor of #215