spring-cloud / spring-cloud/spring-cloud-netflix

Ribbon integration keeps reference to "old" ApplicationContexts even when using @DirtiesContext on Undertow

Open
#2,147 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

icebox
Dominant language
Java
Stars
5k
Forks
2.5k
Avg merge
1d 2h
Merged PRs (30d)
10

Description

The ApplicationContext used by HttpClientRibbonCommandFactory of RibbonRoutingFilter does not seem to be refreshed by the @DirtiesContext annotation on SpringBoot tests.

This causes tests using @DirtiesContext to fail because all tests with a "dirty" context are trying to used an inactive and closed ApplicationContext, which means that this exception is thrown: https://github.com/spring-projects/spring-framework/blob/v4.3.4.RELEASE/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java#L1065

Now, it does not exactly sound like a cause that @DirtiesContext should be able to handle out of the box (though it'd be nice). What would be the best way to refresh the HttpClientRibbonCommandFactory of a RibbonRoutingFilter across test runs?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with HttpClientRibbonCommandFactory and RibbonRoutingFilter in the Undertow test setup, then reproduce the failure across Spring Boot test runs using @DirtiesContext. Trace where the factory retains the ApplicationContext and verify the behavior against the closed-context exception. Done means dirty contexts no longer cause tests to use an inactive ApplicationContext.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
backend, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.