From d2031ff66eec6e9747ecc53de27e1e5a761cebde Mon Sep 17 00:00:00 2001 From: Glenn Renfro Date: Fri, 14 Jun 2019 14:19:39 -0400 Subject: [PATCH] Updated the order in which the TaskLifecycleListener is configured resolves #605 --- .../cloud/task/listener/TaskLifecycleListener.java | 10 ++++++++-- spring-cloud-task-docs/src/main/asciidoc/features.adoc | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskLifecycleListener.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskLifecycleListener.java index 18219a11..cc151362 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskLifecycleListener.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskLifecycleListener.java @@ -45,6 +45,7 @@ import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.SmartLifecycle; +import org.springframework.core.Ordered; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -76,8 +77,8 @@ import org.springframework.util.StringUtils; * @author Michael Minella * @author Glenn Renfro */ -public class TaskLifecycleListener - implements ApplicationListener, SmartLifecycle, DisposableBean { +public class TaskLifecycleListener implements ApplicationListener, + SmartLifecycle, DisposableBean, Ordered { private static final Log logger = LogFactory.getLog(TaskLifecycleListener.class); @@ -432,4 +433,9 @@ public class TaskLifecycleListener public void destroy() { } + @Override + public int getOrder() { + return HIGHEST_PRECEDENCE; + } + } diff --git a/spring-cloud-task-docs/src/main/asciidoc/features.adoc b/spring-cloud-task-docs/src/main/asciidoc/features.adoc index f37789c5..7a83517b 100644 --- a/spring-cloud-task-docs/src/main/asciidoc/features.adoc +++ b/spring-cloud-task-docs/src/main/asciidoc/features.adoc @@ -296,6 +296,7 @@ The following example shows the three annotations in use: } ---- +NOTE: If you using a `ApplicationListener` early in Spring's Lifecycle this could impact TaskLifecycleListener's functionality. [[features-task-execution-listener-Exceptions]] ==== Exceptions Thrown by Task Execution Listener