From e590341ca78c3c6cd48230b45912beba9f4f4d3c Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Mon, 4 Aug 2025 11:50:47 +0300 Subject: [PATCH] Revise Javadoc regarding new ApplicationContext pause() support See gh-35269 --- .../context/ConfigurableApplicationContext.java | 2 +- .../springframework/context/event/ContextPausedEvent.java | 4 ++-- .../test/context/CacheAwareContextLoaderDelegate.java | 4 ++-- .../java/org/springframework/test/context/TestContext.java | 4 ++-- .../test/context/support/DefaultTestContext.java | 4 ++-- .../springframework/test/context/cache/EventTracker.java | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/ConfigurableApplicationContext.java b/spring-context/src/main/java/org/springframework/context/ConfigurableApplicationContext.java index 8dffb08bd69..fe471a2d252 100644 --- a/spring-context/src/main/java/org/springframework/context/ConfigurableApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/ConfigurableApplicationContext.java @@ -223,7 +223,7 @@ public interface ConfigurableApplicationContext extends ApplicationContext, Life /** * Pause all beans in this application context if necessary, and subsequently * restart all auto-startup beans, effectively restoring the lifecycle state - * after {@link #refresh()} (typically after a preceding {@link #stop()} call + * after {@link #refresh()} (typically after a preceding {@link #pause()} call * when a full {@link #start()} of even lazy-starting beans is to be avoided). * @since 7.0 * @see #pause() diff --git a/spring-context/src/main/java/org/springframework/context/event/ContextPausedEvent.java b/spring-context/src/main/java/org/springframework/context/event/ContextPausedEvent.java index 759783bc0b2..6fee1579918 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ContextPausedEvent.java +++ b/spring-context/src/main/java/org/springframework/context/event/ContextPausedEvent.java @@ -35,8 +35,8 @@ import org.springframework.context.ConfigurableApplicationContext; public class ContextPausedEvent extends ContextStoppedEvent { /** - * Create a new {@code ContextRestartedEvent}. - * @param source the {@code ContextPausedEvent} that has been restarted + * Create a new {@code ContextPausedEvent}. + * @param source the {@code ApplicationContext} that has been paused * (must not be {@code null}) */ public ContextPausedEvent(ApplicationContext source) { diff --git a/spring-test/src/main/java/org/springframework/test/context/CacheAwareContextLoaderDelegate.java b/spring-test/src/main/java/org/springframework/test/context/CacheAwareContextLoaderDelegate.java index 0bb844431c6..d9b56d64b80 100644 --- a/spring-test/src/main/java/org/springframework/test/context/CacheAwareContextLoaderDelegate.java +++ b/spring-test/src/main/java/org/springframework/test/context/CacheAwareContextLoaderDelegate.java @@ -169,8 +169,8 @@ public interface CacheAwareContextLoaderDelegate { * for the supplied {@link MergedContextConfiguration} as well as usage of the * application context for its {@linkplain MergedContextConfiguration#getParent() * parent}, recursively. - *
This informs the {@code ContextCache} that the application context(s) can - * be safely {@linkplain org.springframework.context.Lifecycle#stop() stopped} + *
This informs the {@code ContextCache} that the application context(s) can be safely + * {@linkplain org.springframework.context.ConfigurableApplicationContext#pause() paused} * if no other test classes are actively using the same application context(s). * @param key the context key; never {@code null} * @param testClass the test class that is no longer using the application context(s) diff --git a/spring-test/src/main/java/org/springframework/test/context/TestContext.java b/spring-test/src/main/java/org/springframework/test/context/TestContext.java index 9e5ce628843..e345a74c7e2 100644 --- a/spring-test/src/main/java/org/springframework/test/context/TestContext.java +++ b/spring-test/src/main/java/org/springframework/test/context/TestContext.java @@ -135,8 +135,8 @@ public interface TestContext extends AttributeAccessor, Serializable { * Call this method to signal that the {@linkplain #getTestClass() test class} * is no longer using the {@linkplain ApplicationContext application context} * associated with this test context. - *
This informs the context cache that the application context can be - * safely {@linkplain org.springframework.context.Lifecycle#stop() stopped} + *
This informs the context cache that the application context can be safely + * {@linkplain org.springframework.context.ConfigurableApplicationContext#pause() paused} * if no other test classes are actively using the same application context. *
This method is intended to be invoked after execution of the test class * has ended and should not be invoked unless the application context for this diff --git a/spring-test/src/main/java/org/springframework/test/context/support/DefaultTestContext.java b/spring-test/src/main/java/org/springframework/test/context/support/DefaultTestContext.java index 7d9a06045f0..850c752dac2 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/DefaultTestContext.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/DefaultTestContext.java @@ -143,8 +143,8 @@ public class DefaultTestContext implements TestContext { /** * Mark the {@linkplain ApplicationContext application context} associated * with this test context as unused so that it can be safely - * {@linkplain org.springframework.context.Lifecycle#stop() stopped} if no - * other test classes are actively using the same application context. + * {@linkplain org.springframework.context.ConfigurableApplicationContext#pause() paused} + * if no other test classes are actively using the same application context. *
The default implementation delegates to the {@link CacheAwareContextLoaderDelegate} * that was supplied when this {@code TestContext} was constructed. * @since 7.0 diff --git a/spring-test/src/test/java/org/springframework/test/context/cache/EventTracker.java b/spring-test/src/test/java/org/springframework/test/context/cache/EventTracker.java index a606d70ddf0..ed997cd35c7 100644 --- a/spring-test/src/test/java/org/springframework/test/context/cache/EventTracker.java +++ b/spring-test/src/test/java/org/springframework/test/context/cache/EventTracker.java @@ -22,9 +22,9 @@ import java.util.List; import org.springframework.context.ApplicationEvent; import org.springframework.context.event.ApplicationContextEvent; import org.springframework.context.event.ContextClosedEvent; +import org.springframework.context.event.ContextPausedEvent; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.ContextRestartedEvent; -import org.springframework.context.event.ContextStoppedEvent; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; import org.springframework.test.context.event.TestContextEvent; @@ -51,8 +51,8 @@ class EventTracker { trackApplicationContextEvent(event); } - @EventListener(ContextStoppedEvent.class) - void contextStopped(ContextStoppedEvent event) { + @EventListener(ContextPausedEvent.class) + void contextPaused(ContextPausedEvent event) { trackApplicationContextEvent(event); }