Affects: 5.2.6.RELEASE

Original Spring boot issue: https://github.com/spring-projects/spring-boot/issues/21458

Using a configuration similar to: https://springframework.guru/using-ehcache-3-in-spring-boot/

When two contexts are created that use the same cache manager and one of them is closed, it causes the cache manager to close and be invalid for further operations. Continuing tests in the unclosed context that uses the same cache manager results in cache is closed errors.

Sample repository: https://github.com/cdalexndr/spring-boot-issue-21458 Just run gradlew test, output:

Cache[testcache] is closed
java.lang.IllegalStateException: Cache[testcache] is closed
    at org.ehcache.jsr107.Eh107Cache.checkClosed(Eh107Cache.java:543)
    at org.ehcache.jsr107.Eh107Cache.get(Eh107Cache.java:88)
    at org.springframework.cache.jcache.JCacheCache.lookup(JCacheCache.java:78)
    ....

Comment From: snicoll

As I've indicated on the Spring Boot issue, the contexts are not closed properly due to the link between those two test classes.

We could improve the test context framework to have a special handling of JCacheCacheManager due to how the underlying javax.cache.CacheManager is stored but I am not keen to do that.

Forcing a context to close when such bean is present is a bit unexpected and hard to resonate. It would also punish people that configure things correctly. For instance, having only a limited number of tests with full caching enabled to validate the configuration and other tests with the cache disabled or a simpler cache implementation.

Comment From: cdalexndr

If you won't fix this, shouldn't a warning be added to the documentation?