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

job scope bean doesn't cleanup in unit test #1288

Closed
spring-projects-issues opened this issue Oct 28, 2014 · 1 comment
Closed

job scope bean doesn't cleanup in unit test #1288

spring-projects-issues opened this issue Oct 28, 2014 · 1 comment
Labels
for: backport-to-4.3.x Issues that will be back-ported to the 4.3.x line for: backport-to-5.0.x Issues that will be back-ported to the 5.0.x line in: test type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Clockrun Ren opened BATCH-2314 and commented

By using JobScopeTestExecutionListener in my test case (base on testng), I was able to instantiate job scope bean. however, after test method is executed, destroy() in job scope bean is never called.
After some investigation, I find there are issues in class JobScopeTestExecutionListener.

In method afterTestMethod, it will do JobSynchronizationManager.close(). which only remove scoped bean from context, without invoke of destroy(). if we use JobSynchronizationManager.release(), then everything is fine.


Affects: 3.0.1

@cppwfs
Copy link
Contributor

cppwfs commented Jul 28, 2023

Thank you for opening the issue. Can you retry with the latest release of Spring Batch(5.0.2) and report back the results?
If the issue is reproducible, can you provide a sample project that uses the latest release of Spring Batch and that exhibits the behavior? To help you in reporting your issue, we have prepared a project template that you can use as a starting point. Please check the Issue Reporting Guidelines for more details about this.

@cppwfs cppwfs added status: waiting-for-reporter Issues for which we are waiting for feedback from the reporter and removed status: waiting-for-triage Issues that we did not analyse yet labels Jul 28, 2023
@fmbenhassine fmbenhassine changed the title job scope bean doesn't cleanup in unit test [BATCH-2314] job scope bean doesn't cleanup in unit test Nov 21, 2023
@fmbenhassine fmbenhassine added for: backport-to-4.3.x Issues that will be back-ported to the 4.3.x line for: backport-to-5.0.x Issues that will be back-ported to the 5.0.x line and removed status: waiting-for-reporter Issues for which we are waiting for feedback from the reporter labels Nov 21, 2023
@fmbenhassine fmbenhassine added this to the 5.1.0 milestone Nov 21, 2023
fmbenhassine added a commit that referenced this issue Nov 21, 2023
Before this commit, the destroy method of a job-scoped
bean was not called after a test method.

This commit changes the listener to respect the
DisposableBean contract for job-scoped beans (and make it
consistent with the calls to the JobSynchronizationManager
in AbstractJob, ie calling register/release).

FTR, I did not find a clean way to test this with an
assertion (which should be made after the test method),
but a log message in the destroy method shows that the
method is now called as expected.

Resolves #1288

(cherry picked from commit ad50599)
fmbenhassine added a commit that referenced this issue Nov 21, 2023
Before this commit, the destroy method of a job-scoped
bean was not called after a test method.

This commit changes the listener to respect the
DisposableBean contract for job-scoped beans (and make it
consistent with the calls to the JobSynchronizationManager
in AbstractJob, ie calling register/release).

FTR, I did not find a clean way to test this with an
assertion (which should be made after the test method),
but a log message in the destroy method shows that the
method is now called as expected.

Resolves #1288

(cherry picked from commit ad50599)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: backport-to-4.3.x Issues that will be back-ported to the 4.3.x line for: backport-to-5.0.x Issues that will be back-ported to the 5.0.x line in: test type: bug
Projects
None yet
Development

No branches or pull requests

3 participants