diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java index ee292510b53..9d57ac5e968 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java @@ -322,8 +322,8 @@ class ConfigurationClassPostProcessorTests { ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.setEnvironment(new StandardEnvironment()); pp.postProcessBeanFactory(beanFactory); - assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> - beanFactory.getBean(SimpleComponent.class)); + assertThatExceptionOfType(NoSuchBeanDefinitionException.class) + .isThrownBy(() -> beanFactory.getBean(SimpleComponent.class)); } @Test @@ -373,11 +373,11 @@ class ConfigurationClassPostProcessorTests { beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class)); beanFactory.setAllowBeanDefinitionOverriding(false); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); - assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() -> - pp.postProcessBeanFactory(beanFactory)) - .withMessageContaining("bar") - .withMessageContaining("SingletonBeanConfig") - .withMessageContaining(TestBean.class.getName()); + assertThatExceptionOfType(BeanDefinitionStoreException.class) + .isThrownBy(() -> pp.postProcessBeanFactory(beanFactory)) + .withMessageContaining("bar") + .withMessageContaining("SingletonBeanConfig") + .withMessageContaining(TestBean.class.getName()); } @Test // gh-25430 @@ -430,12 +430,12 @@ class ConfigurationClassPostProcessorTests { ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); - assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> - beanFactory.getBean(Bar.class)) - .withMessageContaining("OverridingSingletonBeanConfig.foo") - .withMessageContaining(ExtendedFoo.class.getName()) - .withMessageContaining(Foo.class.getName()) - .withMessageContaining("InvalidOverridingSingletonBeanConfig"); + assertThatExceptionOfType(BeanCreationException.class) + .isThrownBy(() -> beanFactory.getBean(Bar.class)) + .withMessageContaining("OverridingSingletonBeanConfig.foo") + .withMessageContaining(ExtendedFoo.class.getName()) + .withMessageContaining(Foo.class.getName()) + .withMessageContaining("InvalidOverridingSingletonBeanConfig"); } @Test // SPR-15384 @@ -986,16 +986,16 @@ class ConfigurationClassPostProcessorTests { beanFactory.registerBeanDefinition("configClass1", new RootBeanDefinition(A.class)); beanFactory.registerBeanDefinition("configClass2", new RootBeanDefinition(AStrich.class)); new ConfigurationClassPostProcessor().postProcessBeanFactory(beanFactory); - assertThatExceptionOfType(BeanCreationException.class).isThrownBy( - beanFactory::preInstantiateSingletons) - .withMessageContaining("Circular reference"); + assertThatExceptionOfType(BeanCreationException.class) + .isThrownBy(beanFactory::preInstantiateSingletons) + .withMessageContaining("Circular reference"); } @Test void testCircularDependencyWithApplicationContext() { - assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> - new AnnotationConfigApplicationContext(A.class, AStrich.class)) - .withMessageContaining("Circular reference"); + assertThatExceptionOfType(BeanCreationException.class) + .isThrownBy(() -> new AnnotationConfigApplicationContext(A.class, AStrich.class)) + .withMessageContaining("Circular reference"); } @Test @@ -1103,7 +1103,7 @@ class ConfigurationClassPostProcessorTests { @Test void testNameClashBetweenConfigurationClassAndBean() { assertThatExceptionOfType(BeanDefinitionStoreException.class) - .isThrownBy(() -> new AnnotationConfigApplicationContext(MyTestBean.class).getBean("myTestBean", TestBean.class)); + .isThrownBy(() -> new AnnotationConfigApplicationContext(MyTestBean.class).getBean("myTestBean", TestBean.class)); } @Test @@ -1749,7 +1749,6 @@ class ConfigurationClassPostProcessorTests { } public interface DefaultMethodsConfig extends BaseDefaultMethods { - } @Configuration diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java index 3433ad7bece..f0e66428d32 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -619,15 +619,15 @@ class ConfigurationClassProcessingTests { void register(GenericApplicationContext ctx) { ctx.registerBean("spouse", TestBean.class, () -> new TestBean("functional")); - Supplier testBeanSupplier = () -> new TestBean(ctx.getBean("spouse", TestBean.class)); - ctx.registerBean(TestBean.class, - testBeanSupplier, + Supplier testBeanSupplier = + () -> new TestBean(ctx.getBean("spouse", TestBean.class)); + ctx.registerBean(TestBean.class, testBeanSupplier, bd -> bd.setPrimary(true)); } @Bean - public NestedTestBean nestedTestBean(TestBean testBean) { - return new NestedTestBean(testBean.getSpouse().getName()); + public NestedTestBean nestedTestBean(TestBean spouse) { + return new NestedTestBean(spouse.getSpouse().getName()); } } diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationProxyReactorTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationProxyReactorTests.java index f29b7296a12..b201a2cca60 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationProxyReactorTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationProxyReactorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -16,6 +16,7 @@ package org.springframework.validation.beanvalidation; +import java.util.Locale; import java.util.Set; import jakarta.validation.ConstraintViolation; @@ -95,11 +96,18 @@ class MethodValidationProxyReactorTests { } private static MyService initProxy(Object target, boolean adaptViolations) { - Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); - MethodValidationInterceptor interceptor = new MethodValidationInterceptor(() -> validator, adaptViolations); - ProxyFactory factory = new ProxyFactory(target); - factory.addAdvice(interceptor); - return (MyService) factory.getProxy(); + Locale oldDefault = Locale.getDefault(); + Locale.setDefault(Locale.US); + try { + Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); + MethodValidationInterceptor interceptor = new MethodValidationInterceptor(() -> validator, adaptViolations); + ProxyFactory factory = new ProxyFactory(target); + factory.addAdvice(interceptor); + return (MyService) factory.getProxy(); + } + finally { + Locale.setDefault(oldDefault); + } } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/OrderUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/OrderUtils.java index 19fbc577b88..a18253f48ca 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/OrderUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/OrderUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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,7 +38,7 @@ public abstract class OrderUtils { /** Cache marker for a non-annotated Class. */ private static final Object NOT_ANNOTATED = new Object(); - private static final String JAVAX_PRIORITY_ANNOTATION = "jakarta.annotation.Priority"; + private static final String JAKARTA_PRIORITY_ANNOTATION = "jakarta.annotation.Priority"; /** Cache for @Order value (or NOT_ANNOTATED marker) per Class. */ static final Map orderCache = new ConcurrentReferenceHashMap<>(64); @@ -124,7 +124,7 @@ public abstract class OrderUtils { if (orderAnnotation.isPresent()) { return orderAnnotation.getInt(MergedAnnotation.VALUE); } - MergedAnnotation priorityAnnotation = annotations.get(JAVAX_PRIORITY_ANNOTATION); + MergedAnnotation priorityAnnotation = annotations.get(JAKARTA_PRIORITY_ANNOTATION); if (priorityAnnotation.isPresent()) { return priorityAnnotation.getInt(MergedAnnotation.VALUE); } @@ -139,7 +139,7 @@ public abstract class OrderUtils { */ @Nullable public static Integer getPriority(Class type) { - return MergedAnnotations.from(type, SearchStrategy.TYPE_HIERARCHY).get(JAVAX_PRIORITY_ANNOTATION) + return MergedAnnotations.from(type, SearchStrategy.TYPE_HIERARCHY).get(JAKARTA_PRIORITY_ANNOTATION) .getValue(MergedAnnotation.VALUE, Integer.class).orElse(null); } diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java b/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java index 31de9c0f58d..bcf93b242ba 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -589,8 +589,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe if (this.taskExecutor == null) { this.taskExecutor = createDefaultTaskExecutor(); } - else if (this.taskExecutor instanceof SchedulingTaskExecutor ste && - ste.prefersShortLivedTasks() && + else if (this.taskExecutor instanceof SchedulingTaskExecutor ste && ste.prefersShortLivedTasks() && this.maxMessagesPerTask == Integer.MIN_VALUE) { // TaskExecutor indicated a preference for short-lived tasks. According to // setMaxMessagesPerTask javadoc, we'll use 10 message per task in this case diff --git a/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java b/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java index 13d4121eed1..82805076677 100644 --- a/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -105,8 +105,7 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests { void containerAreStartedByDefault() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( EnableJmsDefaultContainerFactoryConfig.class, DefaultBean.class); - JmsListenerContainerTestFactory factory = - context.getBean(JmsListenerContainerTestFactory.class); + JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class); MessageListenerTestContainer container = factory.getListenerContainers().get(0); assertThat(container.isAutoStartup()).isTrue(); assertThat(container.isStarted()).isTrue(); @@ -116,8 +115,7 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests { void containerCanBeStarterViaTheRegistry() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( EnableJmsAutoStartupFalseConfig.class, DefaultBean.class); - JmsListenerContainerTestFactory factory = - context.getBean(JmsListenerContainerTestFactory.class); + JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class); MessageListenerTestContainer container = factory.getListenerContainers().get(0); assertThat(container.isAutoStartup()).isFalse(); assertThat(container.isStarted()).isFalse(); @@ -132,9 +130,9 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( EnableJmsHandlerMethodFactoryConfig.class, ValidationBean.class); - assertThatExceptionOfType(ListenerExecutionFailedException.class).isThrownBy(() -> - testJmsHandlerMethodFactoryConfiguration(context)) - .withCauseInstanceOf(MethodArgumentNotValidException.class); + assertThatExceptionOfType(ListenerExecutionFailedException.class) + .isThrownBy(() -> testJmsHandlerMethodFactoryConfiguration(context)) + .withCauseInstanceOf(MethodArgumentNotValidException.class); } @Override @@ -156,19 +154,20 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests { @Test void composedJmsListeners() { try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( - EnableJmsDefaultContainerFactoryConfig.class, ComposedJmsListenersBean.class)) { - JmsListenerContainerTestFactory simpleFactory = context.getBean("jmsListenerContainerFactory", - JmsListenerContainerTestFactory.class); + EnableJmsDefaultContainerFactoryConfig.class, ComposedJmsListenersBean.class)) { + + JmsListenerContainerTestFactory simpleFactory = + context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class); assertThat(simpleFactory.getListenerContainers()).hasSize(2); - MethodJmsListenerEndpoint first = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainer( - "first").getEndpoint(); + MethodJmsListenerEndpoint first = (MethodJmsListenerEndpoint) + simpleFactory.getListenerContainer("first").getEndpoint(); assertThat(first.getId()).isEqualTo("first"); assertThat(first.getDestination()).isEqualTo("orderQueue"); assertThat(first.getConcurrency()).isNull(); - MethodJmsListenerEndpoint second = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainer( - "second").getEndpoint(); + MethodJmsListenerEndpoint second = (MethodJmsListenerEndpoint) + simpleFactory.getListenerContainer("second").getEndpoint(); assertThat(second.getId()).isEqualTo("second"); assertThat(second.getDestination()).isEqualTo("billingQueue"); assertThat(second.getConcurrency()).isEqualTo("2-10"); @@ -178,9 +177,9 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests { @Test void unknownFactory() { // not found - assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> - new AnnotationConfigApplicationContext(EnableJmsSampleConfig.class, CustomBean.class)) - .withMessageContaining("customFactory"); + assertThatExceptionOfType(BeanCreationException.class) + .isThrownBy(() -> new AnnotationConfigApplicationContext(EnableJmsSampleConfig.class, CustomBean.class)) + .withMessageContaining("customFactory"); } @Test diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerTestFactory.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerTestFactory.java index 3eeb7db1141..0c055f6fabb 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerTestFactory.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerTestFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2024 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. @@ -28,15 +28,13 @@ public class JmsListenerContainerTestFactory implements JmsListenerContainerFact private boolean autoStartup = true; - private final Map listenerContainers = - new LinkedHashMap<>(); + private final Map listenerContainers = new LinkedHashMap<>(); public void setAutoStartup(boolean autoStartup) { this.autoStartup = autoStartup; } - public List getListenerContainers() { return new ArrayList<>(this.listenerContainers.values()); } diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/MessageListenerContainerObservationTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/MessageListenerContainerObservationTests.java index 0335a4400cd..3ecf95eaa86 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/MessageListenerContainerObservationTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/MessageListenerContainerObservationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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,6 +42,7 @@ import static org.junit.jupiter.params.provider.Arguments.arguments; /** * Observation tests for {@link AbstractMessageListenerContainer} implementations. + * * @author Brian Clozel */ class MessageListenerContainerObservationTests { @@ -75,8 +76,8 @@ class MessageListenerContainerObservationTests { assertThat(registry).hasObservationWithNameEqualTo("jms.message.process") .that() .hasHighCardinalityKeyValue("messaging.destination.name", "spring.test.observation"); - listenerContainer.shutdown(); listenerContainer.stop(); + listenerContainer.shutdown(); } @ParameterizedTest(name = "[{index}] {0}") @@ -103,8 +104,8 @@ class MessageListenerContainerObservationTests { assertThat(registry).hasObservationWithNameEqualTo("jms.message.process") .that() .hasHighCardinalityKeyValue("messaging.destination.name", "spring.test.observation"); - listenerContainer.shutdown(); listenerContainer.stop(); + listenerContainer.shutdown(); } static Stream listenerContainers() { diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/SingleConnectionFactory.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/SingleConnectionFactory.java index 79e092fdf70..bcdd395663d 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/SingleConnectionFactory.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/SingleConnectionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -70,13 +70,15 @@ public class SingleConnectionFactory extends DelegatingConnectionFactory private boolean suppressClose; /** Override auto-commit state?. */ - private @Nullable Boolean autoCommit; + @Nullable + private Boolean autoCommit; /** Wrapped Connection. */ private final AtomicReference target = new AtomicReference<>(); /** Proxy Connection. */ - private @Nullable Connection connection; + @Nullable + private Connection connection; private final Mono connectionEmitter;