Revise shutdown phase log message and executor shutdown documentation
Closes gh-32109
This commit is contained in:
parent
a738e4d5fd
commit
08e6df8832
|
@ -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) {
|
||||
|
|
|
@ -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.
|
||||
* <p>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.
|
||||
* <p>Default is {@code false} as of 6.1, triggering an early soft shutdown of
|
||||
* <p>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.
|
||||
* <p>{@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.
|
||||
* <p>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.
|
||||
* <p>Default is {@code false}, with a coordinated lifecycle stop first (unless
|
||||
* {@link #setAcceptTasksAfterContextClose "acceptTasksAfterContextClose"}
|
||||
* <p>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
|
||||
|
|
Loading…
Reference in New Issue