Skip to content

Commit

Permalink
Expose isClosed() method on AbstractApplicationContext
Browse files Browse the repository at this point in the history
Closes gh-33058
  • Loading branch information
jhoeller committed Jun 17, 2024
1 parent 5c68f3f commit 6561490
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,18 @@ public interface ConfigurableApplicationContext extends ApplicationContext, Life
@Override
void close();

/**
* Return whether this context has been closed already, that is,
* whether {@link #close()} has been called on an active context
* in order to initiate its shutdown.
* <p>Note: This does not indicate whether context shutdown has completed.
* Use {@link #isActive()} for differentiating between those scenarios:
* a context becomes inactive once it has been fully shut down and the
* original {@code close()} call has returned.
* @since 6.2
*/
boolean isClosed();

/**
* Determine whether this application context is active, that is,
* whether it has been refreshed at least once and has not been closed yet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,11 @@ protected void onClose() {
// For subclasses: do nothing by default.
}

@Override
public boolean isClosed() {
return this.closed.get();
}

@Override
public boolean isActive() {
return this.active.get();
Expand Down

0 comments on commit 6561490

Please sign in to comment.