diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index 77625b122a0..a80513286f4 100644 --- a/changes/en-us/2.x.md +++ b/changes/en-us/2.x.md @@ -49,6 +49,7 @@ Add changes here for all PR submitted to the 2.x branch. - [[#6227](https://github.com/apache/incubator-seata/pull/6227)] validate that the primary key is free of illegal characters - [[#6004](https://github.com/apache/incubator-seata/pull/6004)] optimize RM TM startup connect server fail fast - [[#6243](https://github.com/apache/incubator-seata/pull/6243)] optimize links in the console header +- [[#6245](https://github.com/apache/incubator-seata/pull/6245)] in file mode, the configuration in the application takes effect, when the spring configuration in the configuration center is changed - [[#6247](https://github.com/apache/incubator-seata/pull/6247)] optimize asf.yml ### security: diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md index 03c5bd7d9f8..79e0ce2ab48 100644 --- a/changes/zh-cn/2.x.md +++ b/changes/zh-cn/2.x.md @@ -48,8 +48,10 @@ - [[#6227](https://github.com/apache/incubator-seata/pull/6227)] 校验pk中不含逗号 - [[#6004](https://github.com/apache/incubator-seata/pull/6004)] 优化RM,TM连接server快速失败 - [[#6243](https://github.com/apache/incubator-seata/pull/6243)] 优化控制台页眉中的链接 +- [[#6245](https://github.com/apache/incubator-seata/pull/6245)] file模式下,在配置中心的spring配置改变时,使应用程序中的配置生效 - [[#6247](https://github.com/apache/incubator-seata/pull/6247)] 优化 asf.yml 配置 + ### security: - [[#6069](https://github.com/apache/incubator-seata/pull/6069)] 升级Guava依赖版本,修复安全漏洞 - [[#6144](https://github.com/apache/incubator-seata/pull/6144)] 升级Nacos依赖版本至1.4.6 diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringApplicationContextProvider.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringApplicationContextProvider.java index a7b8204c1da..b2f1f87cd1d 100644 --- a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringApplicationContextProvider.java +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/java/io/seata/spring/boot/autoconfigure/provider/SpringApplicationContextProvider.java @@ -20,18 +20,29 @@ import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; +import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ContextClosedEvent; import static io.seata.common.Constants.OBJECT_KEY_SPRING_APPLICATION_CONTEXT; /** * The type spring application context provider */ -public class SpringApplicationContextProvider implements ApplicationContextAware { +public class SpringApplicationContextProvider implements ApplicationContextAware, ApplicationListener { @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - System.setProperty("file.listener.enabled", "false"); ObjectHolder.INSTANCE.setObject(OBJECT_KEY_SPRING_APPLICATION_CONTEXT, applicationContext); } + /** + * Handle an application event. + * + * @param event the event to respond to + */ + @Override + public void onApplicationEvent(ContextClosedEvent event) { + // end the file listener as soon as possible in file config mode + System.setProperty("file.listener.enabled", "false"); + } }