Closed
Description
Gaetan Pitteloud opened SPR-8055 and commented
Overview
The cache of application contexts becomes too big when running a complete suite of tests that each load a full ApplicationContext
with a JPA EntityManagerFactory
. There are situations where a tiny difference in the configuration forces us to load a different context.
Since the context cache is only there for performance reasons, its maximum size should be configurable -- a system property might be the best choice, while no property means unbounded size -- so that the least recently used can be properly closed and evicted from the cache.
Deliverables
- Introduce a mechanism for configuring the maximum number of contexts that should be cached at any given time.
- Possible mechanisms include: simple system property or a system property supported via
SpringProperties
.
- Possible mechanisms include: simple system property or a system property supported via
- Redesign
DefaultContextCache
to implement an LRU cache eviction algorithm.- Ensure that evicted contexts get properly closed.
- Consider internally delegating to a third-party implementation such as a Guava cache.
Attachments:
- ContextCache.java (8.22 kB)
- ContextCacheTestCase.java (2.36 kB)
- FixedSizeMapContextCache.java (13.03 kB)
Issue Links:
- Allow for concurrent test execution in the TestContext framework [SPR-5863] #10532 Allow for concurrent test execution in the TestContext framework
- Support 'throw-away' context for a test class [SPR-13722] #18295 Support 'throw-away' context for a test class
- Introduce system property to disable context caching in the TestContext framework [SPR-11576] #16200 Introduce system property to disable context caching in the TestContext framework
- Use soft or weak references for context caching in the TestContext framework [SPR-7687] #12343 Use soft or weak references for context caching in the TestContext framework ("supersedes")
Referenced from: commits e18d5b5, ebeba43
1 votes, 6 watchers