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

Provide a way to determine if a context is in the process of being closed #33058

Closed
wilkinsona opened this issue Jun 17, 2024 · 2 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@wilkinsona
Copy link
Member

In order to tackle spring-projects/spring-boot#41002, we think we need a way to determine if the application context is in the process of being closed. We cannot use isActive() as active isn't set to false until close processing has completed. The closed flag in AbstractApplicationContext looks like it contains the state that we want to be able to see, but there's no accessor for it.

It looks like we might be able to listen for a ContextClosedEvent and store some state to note that a particular context is in the process of being closed. We'd prefer not to use this approach for a couple of reasons:

  • it gives us more state to manage, duplicating something that the application context already knows
  • there's no obvious way for us to clean up that state as there's no call back for when close processing is complete
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 17, 2024
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 17, 2024
@jhoeller jhoeller self-assigned this Jun 17, 2024
@jhoeller jhoeller added this to the 6.2.0-M5 milestone Jun 17, 2024
@jhoeller
Copy link
Contributor

I suppose a public isClosed() method on AbstractApplicationContext would be sufficient for your purposes?

@wilkinsona
Copy link
Member Author

Yes, I think it would. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants