Skip to content

Commit 6561490

Browse files
committed
Expose isClosed() method on AbstractApplicationContext
Closes gh-33058
1 parent 5c68f3f commit 6561490

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

spring-context/src/main/java/org/springframework/context/ConfigurableApplicationContext.java

+12
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,18 @@ public interface ConfigurableApplicationContext extends ApplicationContext, Life
242242
@Override
243243
void close();
244244

245+
/**
246+
* Return whether this context has been closed already, that is,
247+
* whether {@link #close()} has been called on an active context
248+
* in order to initiate its shutdown.
249+
* <p>Note: This does not indicate whether context shutdown has completed.
250+
* Use {@link #isActive()} for differentiating between those scenarios:
251+
* a context becomes inactive once it has been fully shut down and the
252+
* original {@code close()} call has returned.
253+
* @since 6.2
254+
*/
255+
boolean isClosed();
256+
245257
/**
246258
* Determine whether this application context is active, that is,
247259
* whether it has been refreshed at least once and has not been closed yet.

spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java

+5
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,11 @@ protected void onClose() {
12221222
// For subclasses: do nothing by default.
12231223
}
12241224

1225+
@Override
1226+
public boolean isClosed() {
1227+
return this.closed.get();
1228+
}
1229+
12251230
@Override
12261231
public boolean isActive() {
12271232
return this.active.get();

0 commit comments

Comments
 (0)