Polishing
This commit is contained in:
parent
7613bdfdf9
commit
a338a16b29
|
@ -168,7 +168,7 @@ Kotlin::
|
||||||
======
|
======
|
||||||
|
|
||||||
NOTE: Pooling stateless service objects is not usually necessary. We do not believe it should
|
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.
|
pooling is problematic if resources are cached.
|
||||||
|
|
||||||
Simpler pooling is available by using auto-proxying. You can set the `TargetSource` implementations
|
Simpler pooling is available by using auto-proxying. You can set the `TargetSource` implementations
|
||||||
|
|
|
@ -85,7 +85,7 @@ email when someone places an order:
|
||||||
|
|
||||||
// Call the collaborators to persist the 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);
|
SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);
|
||||||
msg.setTo(order.getCustomer().getEmailAddress());
|
msg.setTo(order.getCustomer().getEmailAddress());
|
||||||
msg.setText(
|
msg.setText(
|
||||||
|
|
|
@ -78,8 +78,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).
|
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.
|
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.
|
State-changing HTTP methods and other HTTP conditional request headers such as `If-Match` and
|
||||||
Other strategies at the controller level can avoid the computation and have a broader support for HTTP conditional requests.
|
`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].
|
See xref:web/webmvc/mvc-caching.adoc[HTTP Caching].
|
||||||
|
|
||||||
This filter has a `writeWeakETag` parameter that configures the filter to write weak ETags
|
This filter has a `writeWeakETag` parameter that configures the filter to write weak ETags
|
||||||
|
|
|
@ -131,8 +131,8 @@ class PropertySourceAnnotationTests {
|
||||||
@Test
|
@Test
|
||||||
void withUnresolvablePlaceholder() {
|
void withUnresolvablePlaceholder() {
|
||||||
assertThatExceptionOfType(BeanDefinitionStoreException.class)
|
assertThatExceptionOfType(BeanDefinitionStoreException.class)
|
||||||
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithUnresolvablePlaceholder.class))
|
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithUnresolvablePlaceholder.class))
|
||||||
.withCauseInstanceOf(IllegalArgumentException.class);
|
.withCauseInstanceOf(IllegalArgumentException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -163,8 +163,8 @@ class PropertySourceAnnotationTests {
|
||||||
@Test
|
@Test
|
||||||
void withEmptyResourceLocations() {
|
void withEmptyResourceLocations() {
|
||||||
assertThatExceptionOfType(BeanDefinitionStoreException.class)
|
assertThatExceptionOfType(BeanDefinitionStoreException.class)
|
||||||
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithEmptyResourceLocations.class))
|
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithEmptyResourceLocations.class))
|
||||||
.withCauseInstanceOf(IllegalArgumentException.class);
|
.withCauseInstanceOf(IllegalArgumentException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -256,8 +256,8 @@ class PropertySourceAnnotationTests {
|
||||||
@Test
|
@Test
|
||||||
void withMissingPropertySource() {
|
void withMissingPropertySource() {
|
||||||
assertThatExceptionOfType(BeanDefinitionStoreException.class)
|
assertThatExceptionOfType(BeanDefinitionStoreException.class)
|
||||||
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithMissingPropertySource.class))
|
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithMissingPropertySource.class))
|
||||||
.withCauseInstanceOf(FileNotFoundException.class);
|
.withCauseInstanceOf(FileNotFoundException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -24,6 +24,8 @@ import org.springframework.lang.Nullable;
|
||||||
/**
|
/**
|
||||||
* Descriptor for a {@link org.springframework.core.env.PropertySource PropertySource}.
|
* Descriptor for a {@link org.springframework.core.env.PropertySource PropertySource}.
|
||||||
*
|
*
|
||||||
|
* @author Stephane Nicoll
|
||||||
|
* @since 6.0
|
||||||
* @param locations the locations to consider
|
* @param locations the locations to consider
|
||||||
* @param ignoreResourceNotFound whether a failure to find a property resource
|
* @param ignoreResourceNotFound whether a failure to find a property resource
|
||||||
* should be ignored
|
* should be ignored
|
||||||
|
@ -31,8 +33,6 @@ import org.springframework.lang.Nullable;
|
||||||
* @param propertySourceFactory the type of {@link PropertySourceFactory} to use,
|
* @param propertySourceFactory the type of {@link PropertySourceFactory} to use,
|
||||||
* or {@code null} to use the default
|
* or {@code null} to use the default
|
||||||
* @param encoding the encoding, or {@code null} to use the default encoding
|
* @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.core.env.PropertySource
|
||||||
* @see org.springframework.context.annotation.PropertySource
|
* @see org.springframework.context.annotation.PropertySource
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -115,13 +115,11 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(AsyncEvent event) throws IOException {
|
public void onStartAsync(AsyncEvent event) throws IOException {
|
||||||
this.asyncContext = null;
|
|
||||||
this.asyncCompleted.set(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStartAsync(AsyncEvent event) throws IOException {
|
public void onTimeout(AsyncEvent event) throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -129,7 +127,9 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTimeout(AsyncEvent event) throws IOException {
|
public void onComplete(AsyncEvent event) throws IOException {
|
||||||
|
this.asyncContext = null;
|
||||||
|
this.asyncCompleted.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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;
|
this.logPrefix = logPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartAsync(AsyncEvent event) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTimeout(AsyncEvent event) {
|
public void onTimeout(AsyncEvent event) {
|
||||||
// Should never happen since we call asyncContext.setTimeout(-1)
|
// 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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -145,13 +145,13 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(AsyncEvent event) throws IOException {
|
public void onTimeout(AsyncEvent event) throws IOException {
|
||||||
this.exceptionHandlers.forEach(consumer -> consumer.accept(event.getThrowable()));
|
this.timeoutHandlers.forEach(Runnable::run);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTimeout(AsyncEvent event) throws IOException {
|
public void onError(AsyncEvent event) throws IOException {
|
||||||
this.timeoutHandlers.forEach(Runnable::run);
|
this.exceptionHandlers.forEach(consumer -> consumer.accept(event.getThrowable()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue