From 330848d339bc535f32a3b7c105b78dd7a0a2d9a7 Mon Sep 17 00:00:00 2001 From: Henning Poettker Date: Sat, 19 Nov 2022 18:34:14 +0100 Subject: [PATCH] Make `ScheduledBeanLazyInitializationExcludeFilter` conditional See gh-33276 --- .../task/TaskSchedulingAutoConfiguration.java | 3 ++- .../task/TaskSchedulingAutoConfigurationTests.java | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfiguration.java index 00e4e5dadd66..80dfbba7b27b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -56,6 +56,7 @@ public ThreadPoolTaskScheduler taskScheduler(TaskSchedulerBuilder builder) { } @Bean + @ConditionalOnBean(name = TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME) public static LazyInitializationExcludeFilter scheduledBeanLazyInitializationExcludeFilter() { return new ScheduledBeanLazyInitializationExcludeFilter(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfigurationTests.java index 65257736d086..e43706898768 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -61,6 +61,12 @@ void noSchedulingDoesNotExposeTaskScheduler() { this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean(TaskScheduler.class)); } + @Test + void noSchedulingDoesNotExposeScheduledBeanLazyInitializationExcludeFilter() { + this.contextRunner.run( + (context) -> assertThat(context).doesNotHaveBean(ScheduledBeanLazyInitializationExcludeFilter.class)); + } + @Test void enableSchedulingWithNoTaskExecutorAutoConfiguresOne() { this.contextRunner