In order to tackle https://github.com/spring-projects/spring-boot/issues/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

Comment From: jhoeller

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

Comment From: wilkinsona

Yes, I think it would. Thank you.