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

Custom Test Execution Listener Executed After Context Cleanup (DirtiesContextTestExecutionListener order) #34226

Closed
tfactor2 opened this issue Jan 9, 2025 · 2 comments
Labels
status: duplicate A duplicate of another issue

Comments

@tfactor2
Copy link

tfactor2 commented Jan 9, 2025

We encountered an issue where our custom test execution listener, responsible for cleaning the database after-test, was executed after the ApplicationContext was cleaned up.
The custom listener had the order3000 to prevent conflicts with other internal listeners.
However, we didn't know that DirtiesContextTestExecutionListener has the same order (3000, what a coincidence), leading our cleanup listener to run after the context was marked dirty.

This behavior led to unexpected results - Spring initiated a new context since the previous one was removed, resulting in the database being cleaned for another test.

It would be great to understand the rationale behind order 3000 for DirtiesContextTestExecutionListener.

Looks like the logic should be more complex:
after method marking should be executed the last (having listener with the lowest order value)
before method marking should be executed the first (listener with the highest order value).

Spring Version: 6.1.13

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 9, 2025
@snicoll
Copy link
Member

snicoll commented Jan 9, 2025

No idea why this was reported twice. Duplicate #34225

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2025
@snicoll snicoll added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 9, 2025
@tfactor2
Copy link
Author

tfactor2 commented Jan 9, 2025

I got a session expired, but apparently, github managed to create a ticket - didn't notice that. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants