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
10c3c080
Commit
10c3c080
authored
Aug 27, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14212 from izeye:polish-20180828
* pr/14212: Polish
parents
a86d7cdb
cf17106d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
26 deletions
+31
-26
TaskSchedulingProperties.java
...ork/boot/autoconfigure/task/TaskSchedulingProperties.java
+1
-0
spring.factories
...utoconfigure/src/main/resources/META-INF/spring.factories
+1
-1
TaskSchedulingAutoConfigurationTests.java
...oconfigure/task/TaskSchedulingAutoConfigurationTests.java
+2
-2
WebFluxAutoConfigurationTests.java
...configure/web/reactive/WebFluxAutoConfigurationTests.java
+2
-2
spring-boot-features.adoc
...ing-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+2
-2
PropertyMapperTests.java
...ramework/boot/context/properties/PropertyMapperTests.java
+1
-1
TaskSchedulerBuilderTests.java
.../springframework/boot/task/TaskSchedulerBuilderTests.java
+22
-18
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskSchedulingProperties.java
View file @
10c3c080
...
@@ -22,6 +22,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
...
@@ -22,6 +22,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* Configuration properties for task scheduling.
* Configuration properties for task scheduling.
*
*
* @author Stephane Nicoll
* @author Stephane Nicoll
* @since 2.1.0
*/
*/
@ConfigurationProperties
(
"spring.task.scheduling"
)
@ConfigurationProperties
(
"spring.task.scheduling"
)
public
class
TaskSchedulingProperties
{
public
class
TaskSchedulingProperties
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories
View file @
10c3c080
...
@@ -96,7 +96,6 @@ org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration,\
...
@@ -96,7 +96,6 @@ org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration,\
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,\
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,\
org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration,\
org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration,\
org.springframework.boot.autoconfigure.reactor.core.ReactorCoreAutoConfiguration,\
org.springframework.boot.autoconfigure.reactor.core.ReactorCoreAutoConfiguration,\
org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration,\
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration,\
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration,\
org.springframework.boot.autoconfigure.security.servlet.SecurityRequestMatcherProviderAutoConfiguration,\
org.springframework.boot.autoconfigure.security.servlet.SecurityRequestMatcherProviderAutoConfiguration,\
org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration,\
org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration,\
...
@@ -111,6 +110,7 @@ org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2Re
...
@@ -111,6 +110,7 @@ org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2Re
org.springframework.boot.autoconfigure.security.oauth2.resource.reactive.ReactiveOAuth2ResourceServerAutoConfiguration,\
org.springframework.boot.autoconfigure.security.oauth2.resource.reactive.ReactiveOAuth2ResourceServerAutoConfiguration,\
org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration,\
org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration,\
org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration,\
org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration,\
org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration,\
org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\
org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfigurationTests.java
View file @
10c3c080
...
@@ -16,8 +16,8 @@
...
@@ -16,8 +16,8 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
task
;
package
org
.
springframework
.
boot
.
autoconfigure
.
task
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -158,7 +158,7 @@ public class TaskSchedulingAutoConfigurationTests {
...
@@ -158,7 +158,7 @@ public class TaskSchedulingAutoConfigurationTests {
static
class
TestBean
{
static
class
TestBean
{
private
final
Set
<
String
>
threadNames
=
new
HashSet
<>
();
private
final
Set
<
String
>
threadNames
=
ConcurrentHashMap
.
newKeySet
();
@Scheduled
(
fixedRate
=
10
)
@Scheduled
(
fixedRate
=
10
)
public
void
accumulate
()
{
public
void
accumulate
()
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java
View file @
10c3c080
...
@@ -517,7 +517,7 @@ public class WebFluxAutoConfigurationTests {
...
@@ -517,7 +517,7 @@ public class WebFluxAutoConfigurationTests {
static
class
CustomRequestMappingHandlerAdapter
{
static
class
CustomRequestMappingHandlerAdapter
{
@Bean
@Bean
public
WebFluxRegistrations
web
Mvc
RegistrationsHandlerAdapter
()
{
public
WebFluxRegistrations
web
Flux
RegistrationsHandlerAdapter
()
{
return
new
WebFluxRegistrations
()
{
return
new
WebFluxRegistrations
()
{
@Override
@Override
...
@@ -546,7 +546,7 @@ public class WebFluxAutoConfigurationTests {
...
@@ -546,7 +546,7 @@ public class WebFluxAutoConfigurationTests {
static
class
CustomRequestMappingHandlerMapping
{
static
class
CustomRequestMappingHandlerMapping
{
@Bean
@Bean
public
WebFluxRegistrations
web
Mvc
RegistrationsHandlerMapping
()
{
public
WebFluxRegistrations
web
Flux
RegistrationsHandlerMapping
()
{
return
new
WebFluxRegistrations
()
{
return
new
WebFluxRegistrations
()
{
@Override
@Override
...
...
spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
10c3c080
...
@@ -6201,11 +6201,11 @@ tasks), the thread pool increases to maximum 16 threads. Shrinking of the pool i
...
@@ -6201,11 +6201,11 @@ tasks), the thread pool increases to maximum 16 threads. Shrinking of the pool i
aggressive as threads are reclaimed when they are idle for 10 seconds (rather than
aggressive as threads are reclaimed when they are idle for 10 seconds (rather than
60 seconds by default).
60 seconds by default).
A `ThreadPoolTaskScheduler` can also be auto-configured if need to be
to be
associated to
A `ThreadPoolTaskScheduler` can also be auto-configured if need to be associated to
scheduled task execution (`@EnableScheduling`). The thread pool uses one thread by default
scheduled task execution (`@EnableScheduling`). The thread pool uses one thread by default
and those settings can be fine-tuned using the `spring.task.scheduling` namespace.
and those settings can be fine-tuned using the `spring.task.scheduling` namespace.
Both a `TaskExecutorBuilder`
and
`TaskSchedulerBuilder` bean are made available in the
Both a `TaskExecutorBuilder`
bean and a
`TaskSchedulerBuilder` bean are made available in the
context if a custom executor or scheduler needs to be created.
context if a custom executor or scheduler needs to be created.
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/PropertyMapperTests.java
View file @
10c3c080
...
@@ -52,7 +52,7 @@ public class PropertyMapperTests {
...
@@ -52,7 +52,7 @@ public class PropertyMapperTests {
}
}
@Test
@Test
public
void
fromValueAsIntShouldAdapt
Supplier
()
{
public
void
fromValueAsIntShouldAdapt
Value
()
{
Integer
result
=
this
.
map
.
from
(
"123"
).
asInt
(
Long:
:
valueOf
)
Integer
result
=
this
.
map
.
from
(
"123"
).
asInt
(
Long:
:
valueOf
)
.
toInstance
(
Integer:
:
new
);
.
toInstance
(
Integer:
:
new
);
assertThat
(
result
).
isEqualTo
(
123
);
assertThat
(
result
).
isEqualTo
(
123
);
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskSchedulerBuilderTests.java
View file @
10c3c080
...
@@ -22,11 +22,14 @@ import java.util.Set;
...
@@ -22,11 +22,14 @@ import java.util.Set;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.ExpectedException
;
import
org.mockito.Mockito
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
spy
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
verifyZeroInteractions
;
/**
/**
* Tests for {@link TaskSchedulerBuilder}.
* Tests for {@link TaskSchedulerBuilder}.
...
@@ -55,8 +58,9 @@ public class TaskSchedulerBuilderTests {
...
@@ -55,8 +58,9 @@ public class TaskSchedulerBuilderTests {
@Test
@Test
public
void
threadNamePrefixShouldApply
()
{
public
void
threadNamePrefixShouldApply
()
{
ThreadPoolTaskScheduler
executor
=
this
.
builder
.
threadNamePrefix
(
"test-"
).
build
();
ThreadPoolTaskScheduler
scheduler
=
this
.
builder
.
threadNamePrefix
(
"test-"
)
assertThat
(
executor
.
getThreadNamePrefix
()).
isEqualTo
(
"test-"
);
.
build
();
assertThat
(
scheduler
.
getThreadNamePrefix
()).
isEqualTo
(
"test-"
);
}
}
@Test
@Test
...
@@ -75,30 +79,30 @@ public class TaskSchedulerBuilderTests {
...
@@ -75,30 +79,30 @@ public class TaskSchedulerBuilderTests {
@Test
@Test
public
void
customizersShouldApply
()
{
public
void
customizersShouldApply
()
{
TaskSchedulerCustomizer
customizer
=
Mockito
.
mock
(
TaskSchedulerCustomizer
.
class
);
TaskSchedulerCustomizer
customizer
=
mock
(
TaskSchedulerCustomizer
.
class
);
ThreadPoolTaskScheduler
executo
r
=
this
.
builder
.
customizers
(
customizer
).
build
();
ThreadPoolTaskScheduler
schedule
r
=
this
.
builder
.
customizers
(
customizer
).
build
();
Mockito
.
verify
(
customizer
).
customize
(
executo
r
);
verify
(
customizer
).
customize
(
schedule
r
);
}
}
@Test
@Test
public
void
customizersShouldBeAppliedLast
()
{
public
void
customizersShouldBeAppliedLast
()
{
ThreadPoolTaskScheduler
scheduler
=
Mockito
.
spy
(
new
ThreadPoolTaskScheduler
());
ThreadPoolTaskScheduler
scheduler
=
spy
(
new
ThreadPoolTaskScheduler
());
this
.
builder
.
poolSize
(
4
).
threadNamePrefix
(
"test-"
)
this
.
builder
.
poolSize
(
4
).
threadNamePrefix
(
"test-"
)
.
additionalCustomizers
((
taskScheduler
)
->
{
.
additionalCustomizers
((
taskScheduler
)
->
{
Mockito
.
verify
(
taskScheduler
).
setPoolSize
(
4
);
verify
(
taskScheduler
).
setPoolSize
(
4
);
Mockito
.
verify
(
taskScheduler
).
setThreadNamePrefix
(
"test-"
);
verify
(
taskScheduler
).
setThreadNamePrefix
(
"test-"
);
});
});
this
.
builder
.
configure
(
scheduler
);
this
.
builder
.
configure
(
scheduler
);
}
}
@Test
@Test
public
void
customizersShouldReplaceExisting
()
{
public
void
customizersShouldReplaceExisting
()
{
TaskSchedulerCustomizer
customizer1
=
Mockito
.
mock
(
TaskSchedulerCustomizer
.
class
);
TaskSchedulerCustomizer
customizer1
=
mock
(
TaskSchedulerCustomizer
.
class
);
TaskSchedulerCustomizer
customizer2
=
Mockito
.
mock
(
TaskSchedulerCustomizer
.
class
);
TaskSchedulerCustomizer
customizer2
=
mock
(
TaskSchedulerCustomizer
.
class
);
ThreadPoolTaskScheduler
executo
r
=
this
.
builder
.
customizers
(
customizer1
)
ThreadPoolTaskScheduler
schedule
r
=
this
.
builder
.
customizers
(
customizer1
)
.
customizers
(
Collections
.
singleton
(
customizer2
)).
build
();
.
customizers
(
Collections
.
singleton
(
customizer2
)).
build
();
Mockito
.
verifyZeroInteractions
(
customizer1
);
verifyZeroInteractions
(
customizer1
);
Mockito
.
verify
(
customizer2
).
customize
(
executo
r
);
verify
(
customizer2
).
customize
(
schedule
r
);
}
}
@Test
@Test
...
@@ -117,12 +121,12 @@ public class TaskSchedulerBuilderTests {
...
@@ -117,12 +121,12 @@ public class TaskSchedulerBuilderTests {
@Test
@Test
public
void
additionalCustomizersShouldAddToExisting
()
{
public
void
additionalCustomizersShouldAddToExisting
()
{
TaskSchedulerCustomizer
customizer1
=
Mockito
.
mock
(
TaskSchedulerCustomizer
.
class
);
TaskSchedulerCustomizer
customizer1
=
mock
(
TaskSchedulerCustomizer
.
class
);
TaskSchedulerCustomizer
customizer2
=
Mockito
.
mock
(
TaskSchedulerCustomizer
.
class
);
TaskSchedulerCustomizer
customizer2
=
mock
(
TaskSchedulerCustomizer
.
class
);
ThreadPoolTaskScheduler
scheduler
=
this
.
builder
.
customizers
(
customizer1
)
ThreadPoolTaskScheduler
scheduler
=
this
.
builder
.
customizers
(
customizer1
)
.
additionalCustomizers
(
customizer2
).
build
();
.
additionalCustomizers
(
customizer2
).
build
();
Mockito
.
verify
(
customizer1
).
customize
(
scheduler
);
verify
(
customizer1
).
customize
(
scheduler
);
Mockito
.
verify
(
customizer2
).
customize
(
scheduler
);
verify
(
customizer2
).
customize
(
scheduler
);
}
}
}
}
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