diff --git a/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java b/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java index f1680b3617..4b23ee07e9 100644 --- a/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -490,9 +490,9 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor try { latch.await(this.timeout, TimeUnit.MILLISECONDS); if (latch.getCount() > 0 && !countDownBeanNames.isEmpty() && logger.isInfoEnabled()) { - logger.info("Failed to shut down " + countDownBeanNames.size() + " bean" + - (countDownBeanNames.size() > 1 ? "s" : "") + " with phase value " + - this.phase + " within timeout of " + this.timeout + "ms: " + countDownBeanNames); + logger.info("Shutdown phase " + this.phase + " ends with " + countDownBeanNames.size() + + " bean" + (countDownBeanNames.size() > 1 ? "s" : "") + + " still running after timeout of " + this.timeout + "ms: " + countDownBeanNames); } } catch (InterruptedException ex) { diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java index d6838f5beb..6b44e21aeb 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,7 +91,7 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac /** * Set the ThreadFactory to use for the ExecutorService's thread pool. - * Default is the underlying ExecutorService's default thread factory. + * THe default is the underlying ExecutorService's default thread factory. *

In a Jakarta EE or other managed environment with JSR-236 support, * consider specifying a JNDI-located ManagedThreadFactory: by default, * to be found at "java:comp/DefaultManagedThreadFactory". @@ -115,7 +115,7 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac /** * Set the RejectedExecutionHandler to use for the ExecutorService. - * Default is the ExecutorService's default abort policy. + * The default is the ExecutorService's default abort policy. * @see java.util.concurrent.ThreadPoolExecutor.AbortPolicy */ public void setRejectedExecutionHandler(@Nullable RejectedExecutionHandler rejectedExecutionHandler) { @@ -126,19 +126,25 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac /** * Set whether to accept further tasks after the application context close phase * has begun. - *

Default is {@code false} as of 6.1, triggering an early soft shutdown of + *

The default is {@code false} as of 6.1, triggering an early soft shutdown of * the executor and therefore rejecting any further task submissions. Switch this * to {@code true} in order to let other components submit tasks even during their * own stop and destruction callbacks, at the expense of a longer shutdown phase. * The executor will not go through a coordinated lifecycle stop phase then - * but rather only stop tasks on its own shutdown. This usually goes along with - * {@link #setWaitForTasksToCompleteOnShutdown "waitForTasksToCompleteOnShutdown"}. + * but rather only stop tasks on its own shutdown. + *

{@code acceptTasksAfterContextClose=true} like behavior also follows from + * {@link #setWaitForTasksToCompleteOnShutdown "waitForTasksToCompleteOnShutdown"} + * which effectively is a specific variant of this flag, replacing the early soft + * shutdown in the concurrent managed stop phase with a serial soft shutdown in + * the executor's destruction step, with individual awaiting according to the + * {@link #setAwaitTerminationSeconds "awaitTerminationSeconds"} property. *

This flag will only have effect when the executor is running in a Spring * application context and able to receive the {@link ContextClosedEvent}. * @since 6.1 * @see org.springframework.context.ConfigurableApplicationContext#close() * @see DisposableBean#destroy() * @see #shutdown() + * @see #setAwaitTerminationSeconds */ public void setAcceptTasksAfterContextClose(boolean acceptTasksAfterContextClose) { this.acceptTasksAfterContextClose = acceptTasksAfterContextClose; @@ -147,8 +153,8 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac /** * Set whether to wait for scheduled tasks to complete on shutdown, * not interrupting running tasks and executing all tasks in the queue. - *

Default is {@code false}, with a coordinated lifecycle stop first (unless - * {@link #setAcceptTasksAfterContextClose "acceptTasksAfterContextClose"} + *

The default is {@code false}, with a coordinated lifecycle stop first + * (unless {@link #setAcceptTasksAfterContextClose "acceptTasksAfterContextClose"} * has been set) and then an immediate shutdown through interrupting ongoing * tasks and clearing the queue. Switch this flag to {@code true} if you * prefer fully completed tasks at the expense of a longer shutdown phase. @@ -162,6 +168,8 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac * property instead of or in addition to this property. * @see java.util.concurrent.ExecutorService#shutdown() * @see java.util.concurrent.ExecutorService#shutdownNow() + * @see #shutdown() + * @see #setAwaitTerminationSeconds */ public void setWaitForTasksToCompleteOnShutdown(boolean waitForJobsToCompleteOnShutdown) { this.waitForTasksToCompleteOnShutdown = waitForJobsToCompleteOnShutdown; @@ -326,7 +334,7 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac } /** - * Cancel the given remaining task which never commended execution, + * Cancel the given remaining task which never commenced execution, * as returned from {@link ExecutorService#shutdownNow()}. * @param task the task to cancel (typically a {@link RunnableFuture}) * @since 5.0.5