Skip to content

Commit e5ae92c

Browse files
committed
Merge pull request #37393 from izeye
* gh-37393: Polish Closes gh-37393
2 parents 8599f8e + 8f4ccb0 commit e5ae92c

File tree

5 files changed

+24
-37
lines changed

5 files changed

+24
-37
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public Spec getSpec() {
130130
public static class Spec {
131131

132132
/**
133-
* Sub-protocol to use in websocket handshake signature.
133+
* Sub-protocols to use in websocket handshake signature.
134134
*/
135135
private String protocols;
136136

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfigurationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.concurrent.ScheduledExecutorService;
2727
import java.util.concurrent.TimeUnit;
2828

29+
import org.assertj.core.api.InstanceOfAssertFactories;
2930
import org.awaitility.Awaitility;
3031
import org.junit.jupiter.api.Test;
3132
import org.junit.jupiter.api.condition.EnabledForJreRange;
@@ -49,7 +50,6 @@
4950
import org.springframework.scheduling.annotation.SchedulingConfigurer;
5051
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
5152
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
52-
import org.springframework.test.util.ReflectionTestUtils;
5353

5454
import static org.assertj.core.api.Assertions.assertThat;
5555

@@ -161,9 +161,9 @@ void simpleAsyncTaskSchedulerBuilderShouldApplyCustomizers() {
161161
.run((context) -> {
162162
assertThat(context).hasSingleBean(SimpleAsyncTaskSchedulerBuilder.class);
163163
SimpleAsyncTaskSchedulerBuilder builder = context.getBean(SimpleAsyncTaskSchedulerBuilder.class);
164-
Set<SimpleAsyncTaskSchedulerCustomizer> customizers = (Set<SimpleAsyncTaskSchedulerCustomizer>) ReflectionTestUtils
165-
.getField(builder, "customizers");
166-
assertThat(customizers).as("SimpleAsyncTaskSchedulerBuilder.customizers").contains(customizer);
164+
assertThat(builder).extracting("customizers")
165+
.asInstanceOf(InstanceOfAssertFactories.collection(SimpleAsyncTaskSchedulerCustomizer.class))
166+
.containsExactly(customizer);
167167
});
168168
}
169169

spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/task-execution-and-scheduling.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Those default settings can be fine-tuned using the `spring.task.execution` names
3636
This changes the thread pool to use a bounded queue so that when the queue is full (100 tasks), the thread pool increases to maximum 16 threads.
3737
Shrinking of the pool is more aggressive as threads are reclaimed when they are idle for 10 seconds (rather than 60 seconds by default).
3838

39-
A scheduler can also be auto-configured if need to be associated to scheduled task execution (using `@EnableScheduling` for instance).
39+
A scheduler can also be auto-configured if it needs to be associated with scheduled task execution (using `@EnableScheduling` for instance).
4040
When virtual threads are enabled (using Java 21+ and configprop:spring.threads.virtual.enabled[] set to `true`) this will be a `SimpleAsyncTaskScheduler` that uses virtual threads.
4141
Otherwise, it will be a `ThreadPoolTaskScheduler` with sensible defaults.
4242

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/SimpleAsyncTaskSchedulerBuilder.java

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ public class SimpleAsyncTaskSchedulerBuilder {
4949
private final Set<SimpleAsyncTaskSchedulerCustomizer> customizers;
5050

5151
public SimpleAsyncTaskSchedulerBuilder() {
52-
this.threadNamePrefix = null;
53-
this.customizers = null;
54-
this.concurrencyLimit = null;
55-
this.virtualThreads = null;
52+
this(null, null, null, null);
5653
}
5754

5855
private SimpleAsyncTaskSchedulerBuilder(String threadNamePrefix, Integer concurrencyLimit, Boolean virtualThreads,
@@ -94,11 +91,10 @@ public SimpleAsyncTaskSchedulerBuilder virtualThreads(Boolean virtualThreads) {
9491
}
9592

9693
/**
97-
* Set the {@link SimpleAsyncTaskSchedulerCustomizer
98-
* threadPoolTaskSchedulerCustomizers} that should be applied to the
99-
* {@link SimpleAsyncTaskScheduler}. Customizers are applied in the order that they
100-
* were added after builder configuration has been applied. Setting this value will
101-
* replace any previously configured customizers.
94+
* Set the {@link SimpleAsyncTaskSchedulerCustomizer customizers} that should be
95+
* applied to the {@link SimpleAsyncTaskScheduler}. Customizers are applied in the
96+
* order that they were added after builder configuration has been applied. Setting
97+
* this value will replace any previously configured customizers.
10298
* @param customizers the customizers to set
10399
* @return a new builder instance
104100
* @see #additionalCustomizers(SimpleAsyncTaskSchedulerCustomizer...)
@@ -109,14 +105,13 @@ public SimpleAsyncTaskSchedulerBuilder customizers(SimpleAsyncTaskSchedulerCusto
109105
}
110106

111107
/**
112-
* Set the {@link SimpleAsyncTaskSchedulerCustomizer
113-
* threadPoolTaskSchedulerCustomizers} that should be applied to the
114-
* {@link SimpleAsyncTaskScheduler}. Customizers are applied in the order that they
115-
* were added after builder configuration has been applied. Setting this value will
116-
* replace any previously configured customizers.
108+
* Set the {@link SimpleAsyncTaskSchedulerCustomizer customizers} that should be
109+
* applied to the {@link SimpleAsyncTaskScheduler}. Customizers are applied in the
110+
* order that they were added after builder configuration has been applied. Setting
111+
* this value will replace any previously configured customizers.
117112
* @param customizers the customizers to set
118113
* @return a new builder instance
119-
* @see #additionalCustomizers(SimpleAsyncTaskSchedulerCustomizer...)
114+
* @see #additionalCustomizers(Iterable)
120115
*/
121116
public SimpleAsyncTaskSchedulerBuilder customizers(
122117
Iterable<? extends SimpleAsyncTaskSchedulerCustomizer> customizers) {
@@ -126,10 +121,9 @@ public SimpleAsyncTaskSchedulerBuilder customizers(
126121
}
127122

128123
/**
129-
* Add {@link SimpleAsyncTaskSchedulerCustomizer threadPoolTaskSchedulerCustomizers}
130-
* that should be applied to the {@link SimpleAsyncTaskScheduler}. Customizers are
131-
* applied in the order that they were added after builder configuration has been
132-
* applied.
124+
* Add {@link SimpleAsyncTaskSchedulerCustomizer customizers} that should be applied
125+
* to the {@link SimpleAsyncTaskScheduler}. Customizers are applied in the order that
126+
* they were added after builder configuration has been applied.
133127
* @param customizers the customizers to add
134128
* @return a new builder instance
135129
* @see #customizers(SimpleAsyncTaskSchedulerCustomizer...)
@@ -140,13 +134,12 @@ public SimpleAsyncTaskSchedulerBuilder additionalCustomizers(SimpleAsyncTaskSche
140134
}
141135

142136
/**
143-
* Add {@link SimpleAsyncTaskSchedulerCustomizer threadPoolTaskSchedulerCustomizers}
144-
* that should be applied to the {@link SimpleAsyncTaskScheduler}. Customizers are
145-
* applied in the order that they were added after builder configuration has been
146-
* applied.
137+
* Add {@link SimpleAsyncTaskSchedulerCustomizer customizers} that should be applied
138+
* to the {@link SimpleAsyncTaskScheduler}. Customizers are applied in the order that
139+
* they were added after builder configuration has been applied.
147140
* @param customizers the customizers to add
148141
* @return a new builder instance
149-
* @see #customizers(SimpleAsyncTaskSchedulerCustomizer...)
142+
* @see #customizers(Iterable)
150143
*/
151144
public SimpleAsyncTaskSchedulerBuilder additionalCustomizers(
152145
Iterable<? extends SimpleAsyncTaskSchedulerCustomizer> customizers) {

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/SimpleAsyncTaskSchedulerBuilderTests.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.boot.task;
1818

19-
import java.lang.reflect.Field;
2019
import java.util.Collections;
2120
import java.util.Set;
2221

@@ -25,7 +24,6 @@
2524
import org.junit.jupiter.api.condition.JRE;
2625

2726
import org.springframework.scheduling.concurrent.SimpleAsyncTaskScheduler;
28-
import org.springframework.util.ReflectionUtils;
2927

3028
import static org.assertj.core.api.Assertions.assertThat;
3129
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@@ -59,11 +57,7 @@ void concurrencyLimitShouldApply() {
5957
@EnabledForJreRange(min = JRE.JAVA_21)
6058
void virtualThreadsShouldApply() {
6159
SimpleAsyncTaskScheduler scheduler = this.builder.virtualThreads(true).build();
62-
Field field = ReflectionUtils.findField(SimpleAsyncTaskScheduler.class, "virtualThreadDelegate");
63-
assertThat(field).as("SimpleAsyncTaskScheduler.virtualThreadDelegate").isNotNull();
64-
field.setAccessible(true);
65-
Object virtualThreadDelegate = ReflectionUtils.getField(field, scheduler);
66-
assertThat(virtualThreadDelegate).as("SimpleAsyncTaskScheduler.virtualThreadDelegate").isNotNull();
60+
assertThat(scheduler).extracting("virtualThreadDelegate").isNotNull();
6761
}
6862

6963
@Test

0 commit comments

Comments
 (0)