Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
342212b8
Commit
342212b8
authored
Jan 28, 2019
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.1.x'
parents
a6815bb2
66f60fbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
TaskExecutionAutoConfiguration.java
...ot/autoconfigure/task/TaskExecutionAutoConfiguration.java
+5
-2
TaskExecutionAutoConfigurationTests.java
...toconfigure/task/TaskExecutionAutoConfigurationTests.java
+24
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfiguration.java
View file @
342212b8
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
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.
...
...
@@ -30,12 +30,14 @@ import org.springframework.context.annotation.Configuration;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.core.task.TaskDecorator
;
import
org.springframework.core.task.TaskExecutor
;
import
org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
/**
* {@link EnableAutoConfiguration Auto-configuration} for {@link TaskExecutor}.
*
* @author Stephane Nicoll
* @author Camille Vienot
* @since 2.1.0
*/
@ConditionalOnClass
(
ThreadPoolTaskExecutor
.
class
)
...
...
@@ -79,7 +81,8 @@ public class TaskExecutionAutoConfiguration {
}
@Lazy
@Bean
(
name
=
APPLICATION_TASK_EXECUTOR_BEAN_NAME
)
@Bean
(
name
=
{
APPLICATION_TASK_EXECUTOR_BEAN_NAME
,
AsyncAnnotationBeanPostProcessor
.
DEFAULT_TASK_EXECUTOR_BEAN_NAME
})
@ConditionalOnMissingBean
(
Executor
.
class
)
public
ThreadPoolTaskExecutor
applicationTaskExecutor
(
TaskExecutorBuilder
builder
)
{
return
builder
.
build
();
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java
View file @
342212b8
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
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,6 +38,7 @@ import org.springframework.core.task.TaskExecutor;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.AsyncResult
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.test.util.ReflectionTestUtils
;
...
...
@@ -49,6 +50,7 @@ import static org.mockito.Mockito.verify;
* Tests for {@link TaskExecutionAutoConfiguration}.
*
* @author Stephane Nicoll
* @author Camille Vienot
*/
public
class
TaskExecutionAutoConfigurationTests
{
...
...
@@ -151,6 +153,21 @@ public class TaskExecutionAutoConfigurationTests {
});
}
@Test
public
void
enableAsyncUsesAutoConfiguredOneByDefaultEvenThoughSchedulingIsConfigured
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.task.execution.thread-name-prefix=task-test-"
)
.
withConfiguration
(
AutoConfigurations
.
of
(
TaskSchedulingAutoConfiguration
.
class
))
.
withUserConfiguration
(
AsyncConfiguration
.
class
,
SchedulingConfiguration
.
class
,
TestBean
.
class
)
.
run
((
context
)
->
{
TestBean
bean
=
context
.
getBean
(
TestBean
.
class
);
String
text
=
bean
.
echo
(
"something"
).
get
();
assertThat
(
text
).
contains
(
"task-test-"
).
contains
(
"something"
);
});
}
private
ContextConsumer
<
AssertableApplicationContext
>
assertTaskExecutor
(
Consumer
<
ThreadPoolTaskExecutor
>
taskExecutor
)
{
return
(
context
)
->
{
...
...
@@ -208,6 +225,12 @@ public class TaskExecutionAutoConfigurationTests {
}
@Configuration
@EnableScheduling
static
class
SchedulingConfiguration
{
}
static
class
TestBean
{
@Async
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment