Skip to content

@DirtiesContext does not restart ehcache [SPR-12687] #17068

@spring-projects-issues

Description

@spring-projects-issues

Juraj Misur opened SPR-12687 and commented

If I use @DirtiesContext annotation together with shared (or not) ehcache instance, it does not properly reinitialize the cache, thus taking existing shutdown cache into fresh context.
See attached project.

  • By running mvn test -Dshared=true 3rd test fails on
    java.lang.IllegalStateException: The strings Cache is not alive (STATUS_SHUTDOWN)
  • By running mvn test -Dshared=false 2nd fails on net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM

The only difference between tests is that CachebugApplication2Test have different context configuration + @DirtiesContext annotation.
If you make CachebugApplication2Test configuration the same as 1Test and 2Test, the tests succeed. Also different behavior can be observed when commenting out @DirtiesContext annotation.

The tests should run together, in order: CachebugApplication1Test , CachebugApplication2Test , CachebugApplication3Test


Affects: 3.2.8, 4.1.4

Attachments:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)in: testIssues in the test modulestatus: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions