|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2024 the original author or authors. |
| 2 | + * Copyright 2012-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
19 | 19 | import java.util.concurrent.CompletableFuture;
|
20 | 20 | import java.util.concurrent.CountDownLatch;
|
21 | 21 | import java.util.concurrent.Executor;
|
| 22 | +import java.util.concurrent.ExecutorService; |
| 23 | +import java.util.concurrent.Executors; |
22 | 24 | import java.util.concurrent.Future;
|
23 | 25 | import java.util.concurrent.TimeUnit;
|
24 | 26 | import java.util.concurrent.atomic.AtomicReference;
|
@@ -210,6 +212,13 @@ void taskExecutorWhenHasCustomTaskExecutorShouldBackOff() {
|
210 | 212 | });
|
211 | 213 | }
|
212 | 214 |
|
| 215 | + @Test |
| 216 | + void taskExecutorWhenHasCustomExecutorServiceShouldNotBackOff() { |
| 217 | + this.contextRunner.withUserConfiguration(CustomExecutorServiceConfig.class).run((context) -> { |
| 218 | + assertThat(context).hasSingleBean(TaskExecutor.class); |
| 219 | + }); |
| 220 | + } |
| 221 | + |
213 | 222 | @Test
|
214 | 223 | @EnabledForJreRange(min = JRE.JAVA_21)
|
215 | 224 | void whenVirtualThreadsAreEnabledAndCustomTaskExecutorIsDefinedThenSimpleAsyncTaskExecutorThatUsesVirtualThreadsBacksOff() {
|
@@ -303,12 +312,22 @@ TaskDecorator mockTaskDecorator() {
|
303 | 312 | static class CustomTaskExecutorConfig {
|
304 | 313 |
|
305 | 314 | @Bean
|
306 |
| - Executor customTaskExecutor() { |
| 315 | + TaskExecutor customTaskExecutor() { |
307 | 316 | return new SyncTaskExecutor();
|
308 | 317 | }
|
309 | 318 |
|
310 | 319 | }
|
311 | 320 |
|
| 321 | + @Configuration(proxyBeanMethods = false) |
| 322 | + static class CustomExecutorServiceConfig { |
| 323 | + |
| 324 | + @Bean |
| 325 | + ExecutorService executorService() { |
| 326 | + return Executors.newSingleThreadScheduledExecutor(); |
| 327 | + } |
| 328 | + |
| 329 | + } |
| 330 | + |
312 | 331 | @Configuration(proxyBeanMethods = false)
|
313 | 332 | @EnableAsync
|
314 | 333 | static class AsyncConfiguration {
|
|
0 commit comments