File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
spring-context/src/main/java/org/springframework/scheduling/concurrent Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 27
27
import java .util .concurrent .ScheduledThreadPoolExecutor ;
28
28
import java .util .concurrent .TimeUnit ;
29
29
30
+ import org .apache .commons .logging .LogFactory ;
31
+
30
32
import org .springframework .context .ApplicationContext ;
31
33
import org .springframework .context .ApplicationContextAware ;
32
34
import org .springframework .context .ApplicationListener ;
@@ -183,12 +185,21 @@ protected void doExecute(Runnable task) {
183
185
}
184
186
}
185
187
188
+ private Runnable taskOnSchedulerThread (Runnable task ) {
189
+ return new DelegatingErrorHandlingRunnable (task , TaskUtils .getDefaultErrorHandler (true ));
190
+ }
191
+
186
192
private Runnable scheduledTask (Runnable task ) {
187
- return () -> execute (new DelegatingErrorHandlingRunnable (task , TaskUtils . LOG_AND_PROPAGATE_ERROR_HANDLER ));
193
+ return () -> execute (new DelegatingErrorHandlingRunnable (task , this :: shutdownAwareErrorHandler ));
188
194
}
189
195
190
- private Runnable taskOnSchedulerThread (Runnable task ) {
191
- return new DelegatingErrorHandlingRunnable (task , TaskUtils .getDefaultErrorHandler (true ));
196
+ private void shutdownAwareErrorHandler (Throwable ex ) {
197
+ if (this .scheduledExecutor .isTerminated ()) {
198
+ LogFactory .getLog (getClass ()).debug ("Ignoring scheduled task exception after shutdown" , ex );
199
+ }
200
+ else {
201
+ TaskUtils .getDefaultErrorHandler (true ).handleError (ex );
202
+ }
192
203
}
193
204
194
205
You can’t perform that action at this time.
0 commit comments