Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DirtiesContext used with Webflux, a random port and multiple contexts causes multiple contexts to misbehave #38199

Closed
Dodomix opened this issue Nov 3, 2023 · 4 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@Dodomix
Copy link

Dodomix commented Nov 3, 2023

Bug description

I'm having an issue while running tests using Webflux. Tests are set up to run on a random port and access a controller using HttpClient (I've tested and the same issue happens with WebTestClient). If there are multiple application contexts used for the tests, then @DirtiesContext annotation causes contexts not being cleared to misbehave (to stop allowing connections).

Bug reproduce

Here is the simplest dummy app I've managed to build which replicates the issue: https://github.com/Dodomix/multiple-test-contexts-bug. If you run Test1 -> Test2 -> Test3, Test3 will fail. Each test by itself passes.

Expected behavior

All tests pass.

System info

Java: Temurin 17.0.9

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 3, 2023
@philwebb
Copy link
Member

philwebb commented Nov 6, 2023

I've tracked this down to this call being made to ReactorResourceFactory.

It seems that reactor.netty.http.HttpResources has a shared static so I think that when Test2 stops the context it also stops the shared resources after which Test3 will fail.

@bclozel @rstoyanchev Is this a Framework bug or something we need to configure in Spring Boot. Should we be setting useGlobalResources to false?

@philwebb philwebb added the status: waiting-for-internal-feedback An issue that needs input from a member or another Spring Team label Nov 6, 2023
@Orteke2464
Copy link

Hello. I've the same problem using spring boot 3.2.4, and spring framework libraries version 6.1.5.

For my test, execution steps same with topic.

I had receiving this problem after migration to spring boot 3, in branch with spring boot 2 problem isn't reproduced

@wilkinsona wilkinsona added the for: team-meeting An issue we'd like to discuss as a team to make progress label May 7, 2024
@bclozel
Copy link
Member

bclozel commented May 16, 2024

@philwebb I think setting useGlobalResources is the best solution here. This should only affect runtime performance for memory allocation, this shouldn't be noticeable in tests.

@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged status: waiting-for-internal-feedback An issue that needs input from a member or another Spring Team labels May 16, 2024
@philwebb philwebb modified the milestones: 3.1.x, 3.2.x May 16, 2024
@philwebb philwebb removed the for: team-meeting An issue we'd like to discuss as a team to make progress label May 22, 2024
@philwebb
Copy link
Member

We're going to investigate using a post processor in the tests to change the flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

6 participants