From 0079cb33eb384111c6ad9a3acdf3f98ef25edec1 Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Thu, 27 Mar 2025 09:32:53 +0800 Subject: [PATCH] Remove redundant @Order and add corresponding ArchRule Signed-off-by: Yanming Zhou --- .../build/architecture/ArchitectureRules.java | 31 +++++++++++++++++++ ...obesHealthEndpointGroupsPostProcessor.java | 5 +-- ...entContextConfigurationImportSelector.java | 3 +- .../cache/JCacheCacheConfiguration.java | 6 +--- .../condition/OnBeanCondition.java | 3 -- .../client/RestClientAutoConfiguration.java | 5 +-- .../WebSocketServletAutoConfiguration.java | 5 +-- .../amqp/RabbitAutoConfigurationTests.java | 3 -- .../WebFluxAutoConfigurationTests.java | 1 - .../servlet/WebMvcAutoConfigurationTests.java | 1 - ...SocketMessagingAutoConfigurationTests.java | 3 +- ...DevToolsPropertyDefaultsPostProcessor.java | 5 +-- .../jdbc/TestDatabaseAutoConfiguration.java | 3 -- .../context/ImportsContextCustomizer.java | 5 +-- ...nersLifecycleBeanFactoryPostProcessor.java | 5 +-- ...tcontainersLifecycleBeanPostProcessor.java | 5 +-- .../MissingParameterNamesFailureAnalyzer.java | 5 +-- .../boot/SpringApplicationTests.java | 1 - .../annotation/ConfigurationsTests.java | 2 -- .../ConfigDataLocationResolversTests.java | 3 +- .../boot/util/InstantiatorTests.java | 1 - 21 files changed, 43 insertions(+), 58 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java b/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java index 6fb0390036b5..7e1446dfc907 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java @@ -96,6 +96,8 @@ static List standard() { rules.add(classLevelConfigurationPropertiesShouldNotSpecifyOnlyPrefixAttribute()); rules.add(methodLevelConfigurationPropertiesShouldNotSpecifyOnlyPrefixAttribute()); rules.add(conditionsShouldNotBePublic()); + rules.add(classLevelProhibitRedundantOrderAnnotation()); + rules.add(methodLevelProhibitRedundantOrderAnnotation()); return List.copyOf(rules); } @@ -306,6 +308,35 @@ private static ArchRule conditionsShouldNotBePublic() { .allowEmptyShould(true); } + private static ArchRule classLevelProhibitRedundantOrderAnnotation() { + return ArchRuleDefinition.classes() + .that() + .areAnnotatedWith("org.springframework.core.annotation.Order") + .should(prohibitRedundantOrderAnnotation()) + .allowEmptyShould(true); + } + + private static ArchRule methodLevelProhibitRedundantOrderAnnotation() { + return ArchRuleDefinition.methods() + .that() + .areAnnotatedWith("org.springframework.core.annotation.Order") + .should(prohibitRedundantOrderAnnotation()) + .allowEmptyShould(true); + } + + private static ArchCondition> prohibitRedundantOrderAnnotation() { + return check("prohibit redundant @Order(Ordered.LOWEST_PRECEDENCE) or empty @Order", + (HasAnnotations item, ConditionEvents events) -> { + JavaAnnotation orderAnnotation = item + .getAnnotationOfType("org.springframework.core.annotation.Order"); + int value = (int) orderAnnotation.getProperties().get("value"); + if (value == Integer.MAX_VALUE) { + addViolation(events, item, + orderAnnotation.getDescription() + " should be removed since it's redundant"); + } + }); + } + private static boolean containsOnlySingleType(JavaType[] types, JavaType type) { return types.length == 1 && type.equals(types[0]); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/availability/AvailabilityProbesHealthEndpointGroupsPostProcessor.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/availability/AvailabilityProbesHealthEndpointGroupsPostProcessor.java index fae61a186b35..d80c8d0a2250 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/availability/AvailabilityProbesHealthEndpointGroupsPostProcessor.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/availability/AvailabilityProbesHealthEndpointGroupsPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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. @@ -18,8 +18,6 @@ import org.springframework.boot.actuate.health.HealthEndpointGroups; import org.springframework.boot.actuate.health.HealthEndpointGroupsPostProcessor; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; import org.springframework.core.env.Environment; /** @@ -29,7 +27,6 @@ * @author Phillip Webb * @author Madhura Bhave */ -@Order(Ordered.LOWEST_PRECEDENCE) class AvailabilityProbesHealthEndpointGroupsPostProcessor implements HealthEndpointGroupsPostProcessor { private final boolean addAdditionalPaths; diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelector.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelector.java index 87434fe6f328..e4769149706a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelector.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelector.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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. @@ -47,7 +47,6 @@ * @see ManagementContextConfiguration * @see ImportCandidates */ -@Order(Ordered.LOWEST_PRECEDENCE) class ManagementContextConfigurationImportSelector implements DeferredImportSelector, BeanClassLoaderAware { private ClassLoader classLoader; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java index e040229da3ec..b1c7bc3ee5d3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 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. @@ -41,8 +41,6 @@ import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; import org.springframework.core.io.Resource; import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.util.CollectionUtils; @@ -122,7 +120,6 @@ private Properties createCacheManagerProperties( * as defined per {@link JCacheProviderAvailableCondition} or if a * {@link CacheManager} has already been defined. */ - @Order(Ordered.LOWEST_PRECEDENCE) static class JCacheAvailableCondition extends AnyNestedCondition { JCacheAvailableCondition() { @@ -146,7 +143,6 @@ static class CustomJCacheCacheManager { * {@link CachingProvider} has been found or if the property referring to the provider * to use has been set. */ - @Order(Ordered.LOWEST_PRECEDENCE) static class JCacheProviderAvailableCondition extends SpringBootCondition { @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java index 607fe647843a..2664fa50aefa 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java @@ -50,14 +50,12 @@ import org.springframework.context.annotation.Condition; import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.ConfigurationCondition; -import org.springframework.core.Ordered; import org.springframework.core.ResolvableType; import org.springframework.core.annotation.MergedAnnotation; import org.springframework.core.annotation.MergedAnnotation.Adapt; import org.springframework.core.annotation.MergedAnnotationCollectors; import org.springframework.core.annotation.MergedAnnotationPredicates; import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.Order; import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.core.type.MethodMetadata; import org.springframework.util.Assert; @@ -81,7 +79,6 @@ * @see ConditionalOnMissingBean * @see ConditionalOnSingleCandidate */ -@Order(Ordered.LOWEST_PRECEDENCE) class OnBeanCondition extends FilteringSpringBootCondition implements ConfigurationCondition { @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestClientAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestClientAutoConfiguration.java index af44b3ae12ac..13462cfdd979 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestClientAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestClientAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 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. @@ -34,8 +34,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Scope; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; import org.springframework.web.client.RestClient; import org.springframework.web.client.RestClient.Builder; @@ -58,7 +56,6 @@ public class RestClientAutoConfiguration { @Bean @ConditionalOnMissingBean - @Order(Ordered.LOWEST_PRECEDENCE) HttpMessageConvertersRestClientCustomizer httpMessageConvertersRestClientCustomizer( ObjectProvider messageConverters) { return new HttpMessageConvertersRestClientCustomizer(messageConverters.getIfUnique()); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketServletAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketServletAutoConfiguration.java index 71dda5859aef..789366e4c96a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketServletAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketServletAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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. @@ -38,8 +38,6 @@ import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; /** * Auto configuration for WebSocket servlet server in embedded Tomcat, Jetty or Undertow. @@ -91,7 +89,6 @@ JettyWebSocketServletWebServerCustomizer websocketServletWebServerCustomizer() { @Bean @ConditionalOnNotWarDeployment - @Order(Ordered.LOWEST_PRECEDENCE) @ConditionalOnMissingBean(name = "websocketUpgradeFilterWebServerCustomizer") WebServerFactoryCustomizer websocketUpgradeFilterWebServerCustomizer() { return (factory) -> { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java index a6bdc9fdfc56..976fa5e4aa98 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java @@ -79,7 +79,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Primary; -import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.core.task.VirtualThreadTaskExecutor; import org.springframework.retry.RetryPolicy; @@ -1187,7 +1186,6 @@ MessageRecoverer anotherMessageRecoverer() { static class MultipleRabbitTemplateCustomizersConfiguration { @Bean - @Order(Ordered.LOWEST_PRECEDENCE) RabbitTemplateCustomizer secondCustomizer() { return mock(RabbitTemplateCustomizer.class); } @@ -1356,7 +1354,6 @@ ConnectionFactoryCustomizer connectionFactoryCustomizer() { static class MultipleConnectionFactoryCustomizersConfiguration { @Bean - @Order(Ordered.LOWEST_PRECEDENCE) ConnectionFactoryCustomizer secondCustomizer() { return mock(ConnectionFactoryCustomizer.class); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java index c7bd34d8be9a..3e0c1849c99a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java @@ -1126,7 +1126,6 @@ static class CustomExceptionHandler extends ResponseEntityExceptionHandler { static class OrderedControllerAdviceBeansConfiguration { @ControllerAdvice - @Order static class LowestOrderedControllerAdvice { } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java index a2def5a17b11..aa1bb3cc0981 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java @@ -1566,7 +1566,6 @@ CustomExceptionHandler customExceptionHandler() { static class OrderedControllerAdviceBeansConfiguration { @ControllerAdvice - @Order static class LowestOrderedControllerAdvice { } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java index 1cbb45228483..2c60a2d9d3fc 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 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. @@ -304,7 +304,6 @@ static class CustomHighWebSocketMessageBrokerConfigurer implements WebSocketMess } @Component - @Order(Ordered.LOWEST_PRECEDENCE) static class CustomLowWebSocketMessageBrokerConfigurer implements WebSocketMessageBrokerConfigurer { } diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java index a135e7e46a03..68cced918be3 100755 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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. @@ -31,8 +31,6 @@ import org.springframework.boot.devtools.system.DevToolsEnablementDeducer; import org.springframework.boot.env.EnvironmentPostProcessor; import org.springframework.core.NativeDetector; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.Environment; import org.springframework.core.env.MapPropertySource; @@ -48,7 +46,6 @@ * @author Madhura Bhave * @since 1.3.0 */ -@Order(Ordered.LOWEST_PRECEDENCE) public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostProcessor { private static final Log logger = DevToolsLogFactory.getLog(DevToolsPropertyDefaultsPostProcessor.class); diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfiguration.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfiguration.java index 10b099f61edb..922fcbd8ab85 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfiguration.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfiguration.java @@ -55,8 +55,6 @@ import org.springframework.context.EnvironmentAware; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Role; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.Environment; import org.springframework.core.env.MapPropertySource; @@ -100,7 +98,6 @@ public DataSource dataSource(Environment environment) { return new EmbeddedDataSourceFactory(environment).getEmbeddedDatabase(); } - @Order(Ordered.LOWEST_PRECEDENCE) static class EmbeddedDataSourceBeanFactoryPostProcessor implements BeanDefinitionRegistryPostProcessor { private static final ConfigurationPropertyName DATASOURCE_URL_PROPERTY = ConfigurationPropertyName diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java index 51517cb961d4..d7649b2e1e7e 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 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. @@ -42,11 +42,9 @@ import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; import org.springframework.context.annotation.ImportSelector; import org.springframework.context.support.AbstractApplicationContext; -import org.springframework.core.Ordered; import org.springframework.core.annotation.AnnotationFilter; import org.springframework.core.annotation.MergedAnnotation; import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.Order; import org.springframework.core.style.ToStringCreator; import org.springframework.core.type.AnnotationMetadata; import org.springframework.test.context.ContextCustomizer; @@ -176,7 +174,6 @@ public String[] selectImports(AnnotationMetadata importingClassMetadata) { * {@link BeanDefinitionRegistryPostProcessor} to cleanup temporary configuration * added to load imports. */ - @Order(Ordered.LOWEST_PRECEDENCE) static class ImportsCleanupPostProcessor implements BeanDefinitionRegistryPostProcessor { static final String BEAN_NAME = ImportsCleanupPostProcessor.class.getName(); diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/lifecycle/TestcontainersLifecycleBeanFactoryPostProcessor.java b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/lifecycle/TestcontainersLifecycleBeanFactoryPostProcessor.java index cb193482b588..91d815a7128e 100644 --- a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/lifecycle/TestcontainersLifecycleBeanFactoryPostProcessor.java +++ b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/lifecycle/TestcontainersLifecycleBeanFactoryPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 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. @@ -24,8 +24,6 @@ import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; /** * {@link BeanFactoryPostProcessor} to prevent {@link AutoCloseable} destruction calls so @@ -36,7 +34,6 @@ * @author Stephane Nicoll * @see TestcontainersLifecycleApplicationContextInitializer */ -@Order(Ordered.LOWEST_PRECEDENCE) class TestcontainersLifecycleBeanFactoryPostProcessor implements BeanFactoryPostProcessor { @Override diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/lifecycle/TestcontainersLifecycleBeanPostProcessor.java b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/lifecycle/TestcontainersLifecycleBeanPostProcessor.java index a09d7906c99e..5f0511bfee67 100644 --- a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/lifecycle/TestcontainersLifecycleBeanPostProcessor.java +++ b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/lifecycle/TestcontainersLifecycleBeanPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 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. @@ -41,8 +41,6 @@ import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; import org.springframework.context.ApplicationListener; import org.springframework.context.aot.AbstractAotProcessor; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; import org.springframework.core.log.LogMessage; /** @@ -60,7 +58,6 @@ * @see TestcontainersLifecycleApplicationContextInitializer */ @SuppressWarnings({ "removal", "deprecation" }) -@Order(Ordered.LOWEST_PRECEDENCE) class TestcontainersLifecycleBeanPostProcessor implements DestructionAwareBeanPostProcessor, ApplicationListener { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MissingParameterNamesFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MissingParameterNamesFailureAnalyzer.java index 3eb6c62e2157..79f1ebf152c3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MissingParameterNamesFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MissingParameterNamesFailureAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 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. @@ -21,8 +21,6 @@ import org.springframework.boot.diagnostics.FailureAnalysis; import org.springframework.boot.diagnostics.FailureAnalyzer; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; import org.springframework.util.StringUtils; /** @@ -32,7 +30,6 @@ * * @author Phillip Webb */ -@Order(Ordered.LOWEST_PRECEDENCE) class MissingParameterNamesFailureAnalyzer implements FailureAnalyzer { private static final String USE_PARAMETERS_MESSAGE = "Ensure that the compiler uses the '-parameters' flag"; diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index 97187aad8054..0b6c406eaeff 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -1806,7 +1806,6 @@ static class BeanDefinitionOrderRunnerConfig { private final List runners = new ArrayList<>(); @Bean - @Order CommandLineRunner runnerC() { return (args) -> this.runners.add("runnerC"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/annotation/ConfigurationsTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/annotation/ConfigurationsTests.java index 7143492552d3..551d0097a8af 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/annotation/ConfigurationsTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/annotation/ConfigurationsTests.java @@ -128,7 +128,6 @@ protected Configurations merge(Set> mergedClasses) { } - @Order(Ordered.LOWEST_PRECEDENCE) static class TestSortedConfigurations extends Configurations { protected TestSortedConfigurations(Class... classes) { @@ -146,7 +145,6 @@ protected Configurations merge(Set> mergedClasses) { } - @Order(Ordered.LOWEST_PRECEDENCE) @SuppressWarnings("removal") static class TestDeprecatedSortedConfigurations extends Configurations { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataLocationResolversTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataLocationResolversTests.java index 517b609b141b..4597ec6c5e83 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataLocationResolversTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataLocationResolversTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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. @@ -260,7 +260,6 @@ static class HighestTestResolver extends TestResolver { } - @Order(Ordered.LOWEST_PRECEDENCE) static class LowestTestResolver extends TestResolver { } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/util/InstantiatorTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/util/InstantiatorTests.java index c7e2deec9df8..4c37549bfe66 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/util/InstantiatorTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/util/InstantiatorTests.java @@ -160,7 +160,6 @@ static class WithDefaultConstructorSubclass extends WithDefaultConstructor { } - @Order(Ordered.LOWEST_PRECEDENCE) static class WithMultipleConstructors { WithMultipleConstructors() {