Skip to content

Close contexts when clearing test context cache#36825

Open
Will-thom wants to merge 1 commit into
spring-projects:mainfrom
Will-thom:fix/context-cache-clear-closes-contexts
Open

Close contexts when clearing test context cache#36825
Will-thom wants to merge 1 commit into
spring-projects:mainfrom
Will-thom:fix/context-cache-clear-closes-contexts

Conversation

@Will-thom
Copy link
Copy Markdown

This updates the TestContext Framework cache so that clearing the cache also closes cached ConfigurableApplicationContext instances instead of only dropping the internal references. The implementation reuses the existing removal path, preserving the hierarchy-aware close behavior already used by cache eviction/removal.

The ContextCache contract now documents the close behavior for clear(), and LruContextCacheTests covers both clear() and reset(), since reset() delegates to clear().

Closes gh-26196

Tests:

  • ./gradlew.bat --no-daemon --max-workers=1 :spring-test:test --tests org.springframework.test.context.cache.LruContextCacheTests
  • ./gradlew.bat --no-daemon --max-workers=1 :spring-test:test --tests org.springframework.test.context.cache.ContextCacheTests
  • ./gradlew.bat --no-daemon --max-workers=1 :spring-test:check

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 21, 2026
@bclozel bclozel added the in: test Issues in the test module label May 21, 2026
@sbrannen sbrannen self-assigned this May 22, 2026
@sbrannen sbrannen added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 22, 2026
@sbrannen sbrannen added this to the 7.0.8 milestone May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: test Issues in the test module type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Close all ApplicationContexts in the TestContext framework after all tests have been executed

4 participants