diff --git a/framework-docs/modules/ROOT/pages/core/aop-api/targetsource.adoc b/framework-docs/modules/ROOT/pages/core/aop-api/targetsource.adoc index fdb41e7b4d1..70d19d9fa74 100644 --- a/framework-docs/modules/ROOT/pages/core/aop-api/targetsource.adoc +++ b/framework-docs/modules/ROOT/pages/core/aop-api/targetsource.adoc @@ -168,7 +168,7 @@ Kotlin:: ====== NOTE: Pooling stateless service objects is not usually necessary. We do not believe it should -be the default choice, as most stateless objects are naturally thread safe, and instance +be the default choice, as most stateless objects are naturally thread-safe, and instance pooling is problematic if resources are cached. Simpler pooling is available by using auto-proxying. You can set the `TargetSource` implementations diff --git a/framework-docs/modules/ROOT/pages/core/beans/factory-scopes.adoc b/framework-docs/modules/ROOT/pages/core/beans/factory-scopes.adoc index 8243d755d1e..0b0e00a52d7 100644 --- a/framework-docs/modules/ROOT/pages/core/beans/factory-scopes.adoc +++ b/framework-docs/modules/ROOT/pages/core/beans/factory-scopes.adoc @@ -324,7 +324,6 @@ Kotlin:: - [[beans-factory-scopes-application]] === Application Scope @@ -374,7 +373,6 @@ Kotlin:: - [[beans-factory-scopes-websocket]] === WebSocket Scope @@ -384,7 +382,6 @@ xref:web/websocket/stomp/scope.adoc[WebSocket scope] for more details. - [[beans-factory-scopes-other-injection]] === Scoped Beans as Dependencies diff --git a/framework-docs/modules/ROOT/pages/integration/email.adoc b/framework-docs/modules/ROOT/pages/integration/email.adoc index 610fda7c879..71c1db30523 100644 --- a/framework-docs/modules/ROOT/pages/integration/email.adoc +++ b/framework-docs/modules/ROOT/pages/integration/email.adoc @@ -85,7 +85,7 @@ email when someone places an order: // Call the collaborators to persist the order... - // Create a thread safe "copy" of the template message and customize it + // Create a thread-safe "copy" of the template message and customize it SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage); msg.setTo(order.getCustomer().getEmailAddress()); msg.setText( diff --git a/framework-docs/modules/ROOT/pages/web/webmvc/filters.adoc b/framework-docs/modules/ROOT/pages/web/webmvc/filters.adoc index 8851bc74c24..781d5a1743c 100644 --- a/framework-docs/modules/ROOT/pages/web/webmvc/filters.adoc +++ b/framework-docs/modules/ROOT/pages/web/webmvc/filters.adoc @@ -70,8 +70,9 @@ it does the same, but it also compares the computed value against the `If-None-M request header and, if the two are equal, returns a 304 (NOT_MODIFIED). This strategy saves network bandwidth but not CPU, as the full response must be computed for each request. -State-changing HTTP methods and other HTTP conditional request headers such as `If-Match` and `If-Unmodified-Since` are outside the scope of this filter. -Other strategies at the controller level can avoid the computation and have a broader support for HTTP conditional requests. +State-changing HTTP methods and other HTTP conditional request headers such as `If-Match` and +`If-Unmodified-Since` are outside the scope of this filter. Other strategies at the controller level +can avoid the computation and have a broader support for HTTP conditional requests. See xref:web/webmvc/mvc-caching.adoc[HTTP Caching]. This filter has a `writeWeakETag` parameter that configures the filter to write weak ETags diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java index cdf9307e3d7..b14b9796d03 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java @@ -92,10 +92,10 @@ import org.springframework.util.function.ThrowingSupplier; * Supports autowiring constructors, properties by name, and properties by type. * *

The main template method to be implemented by subclasses is - * {@link #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)}, - * used for autowiring by type. In case of a factory which is capable of searching - * its bean definitions, matching beans will typically be implemented through such - * a search. For other factory styles, simplified matching algorithms can be implemented. + * {@link #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)}, used for + * autowiring. In case of a {@link org.springframework.beans.factory.ListableBeanFactory} + * which is capable of searching its bean definitions, matching beans will typically be + * implemented through such a search. Otherwise, simplified matching can be implemented. * *

Note that this class does not assume or implement bean definition * registry capabilities. See {@link DefaultListableBeanFactory} for an implementation @@ -650,7 +650,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac // Apply SmartInstantiationAwareBeanPostProcessors to predict the // eventual type after a before-instantiation shortcut. if (targetType != null && !mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) { - boolean matchingOnlyFactoryBean = typesToMatch.length == 1 && typesToMatch[0] == FactoryBean.class; + boolean matchingOnlyFactoryBean = (typesToMatch.length == 1 && typesToMatch[0] == FactoryBean.class); for (SmartInstantiationAwareBeanPostProcessor bp : getBeanPostProcessorCache().smartInstantiationAware) { Class predicted = bp.predictBeanType(targetType, beanName); if (predicted != null && diff --git a/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java index a81a074b247..d2ad4817781 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java @@ -130,8 +130,8 @@ class PropertySourceAnnotationTests { @Test void withUnresolvablePlaceholder() { assertThatExceptionOfType(BeanDefinitionStoreException.class) - .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithUnresolvablePlaceholder.class)) - .withCauseInstanceOf(IllegalArgumentException.class); + .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithUnresolvablePlaceholder.class)) + .withCauseInstanceOf(IllegalArgumentException.class); } @Test @@ -162,8 +162,8 @@ class PropertySourceAnnotationTests { @Test void withEmptyResourceLocations() { assertThatExceptionOfType(BeanDefinitionStoreException.class) - .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithEmptyResourceLocations.class)) - .withCauseInstanceOf(IllegalArgumentException.class); + .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithEmptyResourceLocations.class)) + .withCauseInstanceOf(IllegalArgumentException.class); } @Test @@ -245,8 +245,8 @@ class PropertySourceAnnotationTests { @Test void withMissingPropertySource() { assertThatExceptionOfType(BeanDefinitionStoreException.class) - .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithMissingPropertySource.class)) - .withCauseInstanceOf(FileNotFoundException.class); + .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithMissingPropertySource.class)) + .withCauseInstanceOf(FileNotFoundException.class); } @Test diff --git a/spring-core/src/main/java/org/springframework/core/io/support/PropertySourceDescriptor.java b/spring-core/src/main/java/org/springframework/core/io/support/PropertySourceDescriptor.java index 254a1d49d68..c138de88048 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/PropertySourceDescriptor.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/PropertySourceDescriptor.java @@ -24,6 +24,8 @@ import org.springframework.lang.Nullable; /** * Descriptor for a {@link org.springframework.core.env.PropertySource PropertySource}. * + * @author Stephane Nicoll + * @since 6.0 * @param locations the locations to consider * @param ignoreResourceNotFound whether a failure to find a property resource * should be ignored @@ -31,8 +33,6 @@ import org.springframework.lang.Nullable; * @param propertySourceFactory the type of {@link PropertySourceFactory} to use, * or {@code null} to use the default * @param encoding the encoding, or {@code null} to use the default encoding - * @author Stephane Nicoll - * @since 6.0 * @see org.springframework.core.env.PropertySource * @see org.springframework.context.annotation.PropertySource */ diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java index 1ce0313d977..b800fb6ca62 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java @@ -358,8 +358,8 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init (isSuspendingFunction ? (hasSuspendingFlowReturnType ? Flux.class : Mono.class) : method.getReturnType()); ReactiveAdapter adapter = this.reactiveAdapterRegistry.getAdapter(reactiveType); if (adapter == null) { - throw new IllegalStateException("Cannot apply reactive transaction to non-reactive return type: " + - method.getReturnType()); + throw new IllegalStateException("Cannot apply reactive transaction to non-reactive return type [" + + method.getReturnType() + "] with specified transaction manager: " + tm); } return new ReactiveTransactionSupport(adapter); }); diff --git a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpAsyncRequestControl.java b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpAsyncRequestControl.java index db87ffb8e4f..1b50f301021 100644 --- a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpAsyncRequestControl.java +++ b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpAsyncRequestControl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 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. @@ -115,13 +115,11 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ // --------------------------------------------------------------------- @Override - public void onComplete(AsyncEvent event) throws IOException { - this.asyncContext = null; - this.asyncCompleted.set(true); + public void onStartAsync(AsyncEvent event) throws IOException { } @Override - public void onStartAsync(AsyncEvent event) throws IOException { + public void onTimeout(AsyncEvent event) throws IOException { } @Override @@ -129,7 +127,9 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ } @Override - public void onTimeout(AsyncEvent event) throws IOException { + public void onComplete(AsyncEvent event) throws IOException { + this.asyncContext = null; + this.asyncCompleted.set(true); } } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java index 456f85e4b25..500d644e2f1 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -275,6 +275,11 @@ public class ServletHttpHandlerAdapter implements Servlet { this.logPrefix = logPrefix; } + @Override + public void onStartAsync(AsyncEvent event) { + // no-op + } + @Override public void onTimeout(AsyncEvent event) { // Should never happen since we call asyncContext.setTimeout(-1) @@ -341,11 +346,6 @@ public class ServletHttpHandlerAdapter implements Servlet { } }); } - - @Override - public void onStartAsync(AsyncEvent event) { - // no-op - } } diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java b/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java index bfa7513d537..eb46ccb6479 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java @@ -145,13 +145,13 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements } @Override - public void onError(AsyncEvent event) throws IOException { - this.exceptionHandlers.forEach(consumer -> consumer.accept(event.getThrowable())); + public void onTimeout(AsyncEvent event) throws IOException { + this.timeoutHandlers.forEach(Runnable::run); } @Override - public void onTimeout(AsyncEvent event) throws IOException { - this.timeoutHandlers.forEach(Runnable::run); + public void onError(AsyncEvent event) throws IOException { + this.exceptionHandlers.forEach(consumer -> consumer.accept(event.getThrowable())); } @Override