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
c3de4c84
Commit
c3de4c84
authored
Sep 05, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
0252e545
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
88 additions
and
134 deletions
+88
-134
DefaultEndpointObjectNameFactoryTests.java
...e/endpoint/jmx/DefaultEndpointObjectNameFactoryTests.java
+0
-1
CodecsAutoConfiguration.java
...oot/autoconfigure/http/codec/CodecsAutoConfiguration.java
+2
-4
KafkaStreamsAnnotationDrivenConfiguration.java
...gure/kafka/KafkaStreamsAnnotationDrivenConfiguration.java
+2
-5
TaskExecutionAutoConfiguration.java
...ot/autoconfigure/task/TaskExecutionAutoConfiguration.java
+10
-9
TaskSchedulingAutoConfiguration.java
...t/autoconfigure/task/TaskSchedulingAutoConfiguration.java
+5
-5
spring-boot-features.adoc
...ing-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+2
-1
TaskExecutorBuilder.java
...va/org/springframework/boot/task/TaskExecutorBuilder.java
+33
-48
TaskSchedulerBuilder.java
...a/org/springframework/boot/task/TaskSchedulerBuilder.java
+26
-39
TaskExecutorBuilderTests.java
...g/springframework/boot/task/TaskExecutorBuilderTests.java
+4
-11
TaskSchedulerBuilderTests.java
.../springframework/boot/task/TaskSchedulerBuilderTests.java
+4
-11
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/DefaultEndpointObjectNameFactoryTests.java
View file @
c3de4c84
...
...
@@ -101,7 +101,6 @@ public class DefaultEndpointObjectNameFactoryTests {
public
void
generateObjectNameWithUniqueNamesDeprecatedPropertyMismatchMainProperty
()
{
this
.
environment
.
setProperty
(
"spring.jmx.unique-names"
,
"false"
);
this
.
properties
.
setUniqueNames
(
true
);
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"spring.jmx.unique-names"
);
this
.
thrown
.
expectMessage
(
"management.endpoints.jmx.unique-names"
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/codec/CodecsAutoConfiguration.java
View file @
c3de4c84
...
...
@@ -72,10 +72,8 @@ public class CodecsAutoConfiguration {
@Bean
public
CodecCustomizer
loggingCodecCustomizer
(
InsightsProperties
properties
)
{
return
(
configurer
)
->
{
configurer
.
defaultCodecs
().
enableLoggingRequestDetails
(
properties
.
getWeb
().
isLogRequestDetails
());
};
return
(
configurer
)
->
configurer
.
defaultCodecs
().
enableLoggingRequestDetails
(
properties
.
getWeb
().
isLogRequestDetails
());
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaStreamsAnnotationDrivenConfiguration.java
View file @
c3de4c84
...
...
@@ -56,15 +56,12 @@ class KafkaStreamsAnnotationDrivenConfiguration {
Map
<
String
,
Object
>
streamsProperties
=
this
.
properties
.
buildStreamsProperties
();
if
(
this
.
properties
.
getStreams
().
getApplicationId
()
==
null
)
{
String
applicationName
=
environment
.
getProperty
(
"spring.application.name"
);
if
(
applicationName
!=
null
)
{
streamsProperties
.
put
(
StreamsConfig
.
APPLICATION_ID_CONFIG
,
applicationName
);
}
else
{
if
(
applicationName
==
null
)
{
throw
new
InvalidConfigurationPropertyValueException
(
"spring.kafka.streams.application-id"
,
null
,
"This property is mandatory and fallback 'spring.application.name' is not set either."
);
}
streamsProperties
.
put
(
StreamsConfig
.
APPLICATION_ID_CONFIG
,
applicationName
);
}
return
new
KafkaStreamsConfiguration
(
streamsProperties
);
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfiguration.java
View file @
c3de4c84
...
...
@@ -17,7 +17,6 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
task
;
import
java.util.concurrent.Executor
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.ObjectProvider
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
...
...
@@ -66,14 +65,16 @@ public class TaskExecutionAutoConfiguration {
@ConditionalOnMissingBean
public
TaskExecutorBuilder
taskExecutorBuilder
()
{
TaskExecutionProperties
.
Pool
pool
=
this
.
properties
.
getPool
();
return
new
TaskExecutorBuilder
().
queueCapacity
(
pool
.
getQueueCapacity
())
.
corePoolSize
(
pool
.
getCoreSize
()).
maxPoolSize
(
pool
.
getMaxSize
())
.
allowCoreThreadTimeOut
(
pool
.
isAllowCoreThreadTimeout
())
.
keepAlive
(
pool
.
getKeepAlive
())
.
threadNamePrefix
(
this
.
properties
.
getThreadNamePrefix
())
.
customizers
(
this
.
taskExecutorCustomizers
.
stream
()
.
collect
(
Collectors
.
toList
()))
.
taskDecorator
(
this
.
taskDecorator
.
getIfUnique
());
TaskExecutorBuilder
builder
=
new
TaskExecutorBuilder
();
builder
=
builder
.
queueCapacity
(
pool
.
getQueueCapacity
());
builder
=
builder
.
corePoolSize
(
pool
.
getCoreSize
());
builder
=
builder
.
maxPoolSize
(
pool
.
getMaxSize
());
builder
=
builder
.
allowCoreThreadTimeOut
(
pool
.
isAllowCoreThreadTimeout
());
builder
=
builder
.
keepAlive
(
pool
.
getKeepAlive
());
builder
=
builder
.
threadNamePrefix
(
this
.
properties
.
getThreadNamePrefix
());
builder
=
builder
.
customizers
(
this
.
taskExecutorCustomizers
);
builder
=
builder
.
taskDecorator
(
this
.
taskDecorator
.
getIfUnique
());
return
builder
;
}
@Bean
(
name
=
APPLICATION_TASK_EXECUTOR_BEAN_NAME
)
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfiguration.java
View file @
c3de4c84
...
...
@@ -16,8 +16,6 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
task
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.ObjectProvider
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
...
...
@@ -55,9 +53,11 @@ public class TaskSchedulingAutoConfiguration {
@ConditionalOnMissingBean
public
TaskSchedulerBuilder
taskSchedulerBuilder
(
TaskSchedulingProperties
properties
,
ObjectProvider
<
TaskSchedulerCustomizer
>
taskSchedulerCustomizers
)
{
return
new
TaskSchedulerBuilder
().
poolSize
(
properties
.
getPool
().
getSize
())
.
threadNamePrefix
(
properties
.
getThreadNamePrefix
()).
customizers
(
taskSchedulerCustomizers
.
stream
().
collect
(
Collectors
.
toList
()));
TaskSchedulerBuilder
builder
=
new
TaskSchedulerBuilder
();
builder
=
builder
.
poolSize
(
properties
.
getPool
().
getSize
());
builder
=
builder
.
threadNamePrefix
(
properties
.
getThreadNamePrefix
());
builder
=
builder
.
customizers
(
taskSchedulerCustomizers
);
return
builder
;
}
}
spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
c3de4c84
...
...
@@ -5879,9 +5879,9 @@ The following code shows a typical example:
----
[[boot-features-webclient-runtime]]
=== WebClient Runtime
Spring Boot will auto-detect which `ClientHttpConnector` to drive `WebClient`, depending
on the libraries available on the application classpath.
...
...
@@ -5901,6 +5901,7 @@ You can learn more about the
options in the Spring Framework reference documentation].
[[boot-features-webclient-customization]]
=== WebClient Customization
There are three main approaches to `WebClient` customization, depending on how broadly you
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/TaskExecutorBuilder.java
View file @
c3de4c84
...
...
@@ -18,7 +18,6 @@ package org.springframework.boot.task;
import
java.time.Duration
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
...
...
@@ -59,11 +58,9 @@ public class TaskExecutorBuilder {
private
final
TaskDecorator
taskDecorator
;
private
final
Set
<
TaskExecutorCustomizer
>
taskExecutorC
ustomizers
;
private
final
Set
<
TaskExecutorCustomizer
>
c
ustomizers
;
public
TaskExecutorBuilder
(
TaskExecutorCustomizer
...
taskExecutorCustomizers
)
{
Assert
.
notNull
(
taskExecutorCustomizers
,
"TaskExecutorCustomizers must not be null"
);
public
TaskExecutorBuilder
()
{
this
.
queueCapacity
=
null
;
this
.
corePoolSize
=
null
;
this
.
maxPoolSize
=
null
;
...
...
@@ -71,14 +68,13 @@ public class TaskExecutorBuilder {
this
.
keepAlive
=
null
;
this
.
threadNamePrefix
=
null
;
this
.
taskDecorator
=
null
;
this
.
taskExecutorCustomizers
=
Collections
.
unmodifiableSet
(
new
LinkedHashSet
<>(
Arrays
.
asList
(
taskExecutorCustomizers
)));
this
.
customizers
=
null
;
}
p
ublic
TaskExecutorBuilder
(
Integer
queueCapacity
,
Integer
corePoolSize
,
p
rivate
TaskExecutorBuilder
(
Integer
queueCapacity
,
Integer
corePoolSize
,
Integer
maxPoolSize
,
Boolean
allowCoreThreadTimeOut
,
Duration
keepAlive
,
String
threadNamePrefix
,
TaskDecorator
taskDecorator
,
Set
<
TaskExecutorCustomizer
>
taskExecutorC
ustomizers
)
{
Set
<
TaskExecutorCustomizer
>
c
ustomizers
)
{
this
.
queueCapacity
=
queueCapacity
;
this
.
corePoolSize
=
corePoolSize
;
this
.
maxPoolSize
=
maxPoolSize
;
...
...
@@ -86,7 +82,7 @@ public class TaskExecutorBuilder {
this
.
keepAlive
=
keepAlive
;
this
.
threadNamePrefix
=
threadNamePrefix
;
this
.
taskDecorator
=
taskDecorator
;
this
.
taskExecutorCustomizers
=
taskExecutorC
ustomizers
;
this
.
customizers
=
c
ustomizers
;
}
/**
...
...
@@ -98,7 +94,7 @@ public class TaskExecutorBuilder {
public
TaskExecutorBuilder
queueCapacity
(
int
queueCapacity
)
{
return
new
TaskExecutorBuilder
(
queueCapacity
,
this
.
corePoolSize
,
this
.
maxPoolSize
,
this
.
allowCoreThreadTimeOut
,
this
.
keepAlive
,
this
.
threadNamePrefix
,
this
.
taskDecorator
,
this
.
taskExecutorC
ustomizers
);
this
.
taskDecorator
,
this
.
c
ustomizers
);
}
/**
...
...
@@ -113,7 +109,7 @@ public class TaskExecutorBuilder {
public
TaskExecutorBuilder
corePoolSize
(
int
corePoolSize
)
{
return
new
TaskExecutorBuilder
(
this
.
queueCapacity
,
corePoolSize
,
this
.
maxPoolSize
,
this
.
allowCoreThreadTimeOut
,
this
.
keepAlive
,
this
.
threadNamePrefix
,
this
.
taskDecorator
,
this
.
taskExecutorC
ustomizers
);
this
.
taskDecorator
,
this
.
c
ustomizers
);
}
/**
...
...
@@ -128,7 +124,7 @@ public class TaskExecutorBuilder {
public
TaskExecutorBuilder
maxPoolSize
(
int
maxPoolSize
)
{
return
new
TaskExecutorBuilder
(
this
.
queueCapacity
,
this
.
corePoolSize
,
maxPoolSize
,
this
.
allowCoreThreadTimeOut
,
this
.
keepAlive
,
this
.
threadNamePrefix
,
this
.
taskDecorator
,
this
.
taskExecutorC
ustomizers
);
this
.
taskDecorator
,
this
.
c
ustomizers
);
}
/**
...
...
@@ -140,7 +136,7 @@ public class TaskExecutorBuilder {
public
TaskExecutorBuilder
allowCoreThreadTimeOut
(
boolean
allowCoreThreadTimeOut
)
{
return
new
TaskExecutorBuilder
(
this
.
queueCapacity
,
this
.
corePoolSize
,
this
.
maxPoolSize
,
allowCoreThreadTimeOut
,
this
.
keepAlive
,
this
.
threadNamePrefix
,
this
.
taskDecorator
,
this
.
taskExecutorC
ustomizers
);
this
.
threadNamePrefix
,
this
.
taskDecorator
,
this
.
c
ustomizers
);
}
/**
...
...
@@ -151,7 +147,7 @@ public class TaskExecutorBuilder {
public
TaskExecutorBuilder
keepAlive
(
Duration
keepAlive
)
{
return
new
TaskExecutorBuilder
(
this
.
queueCapacity
,
this
.
corePoolSize
,
this
.
maxPoolSize
,
this
.
allowCoreThreadTimeOut
,
keepAlive
,
this
.
threadNamePrefix
,
this
.
taskDecorator
,
this
.
taskExecutorC
ustomizers
);
this
.
threadNamePrefix
,
this
.
taskDecorator
,
this
.
c
ustomizers
);
}
/**
...
...
@@ -162,7 +158,7 @@ public class TaskExecutorBuilder {
public
TaskExecutorBuilder
threadNamePrefix
(
String
threadNamePrefix
)
{
return
new
TaskExecutorBuilder
(
this
.
queueCapacity
,
this
.
corePoolSize
,
this
.
maxPoolSize
,
this
.
allowCoreThreadTimeOut
,
this
.
keepAlive
,
threadNamePrefix
,
this
.
taskDecorator
,
this
.
taskExecutorC
ustomizers
);
threadNamePrefix
,
this
.
taskDecorator
,
this
.
c
ustomizers
);
}
/**
...
...
@@ -173,7 +169,7 @@ public class TaskExecutorBuilder {
public
TaskExecutorBuilder
taskDecorator
(
TaskDecorator
taskDecorator
)
{
return
new
TaskExecutorBuilder
(
this
.
queueCapacity
,
this
.
corePoolSize
,
this
.
maxPoolSize
,
this
.
allowCoreThreadTimeOut
,
this
.
keepAlive
,
this
.
threadNamePrefix
,
taskDecorator
,
this
.
taskExecutorC
ustomizers
);
this
.
threadNamePrefix
,
taskDecorator
,
this
.
c
ustomizers
);
}
/**
...
...
@@ -181,15 +177,13 @@ public class TaskExecutorBuilder {
* applied to the {@link ThreadPoolTaskExecutor}. Customizers are applied in the order
* that they were added after builder configuration has been applied. Setting this
* value will replace any previously configured customizers.
* @param
taskExecutorC
ustomizers the customizers to set
* @param
c
ustomizers the customizers to set
* @return a new builder instance
* @see #additionalCustomizers(TaskExecutorCustomizer...)
*/
public
TaskExecutorBuilder
customizers
(
TaskExecutorCustomizer
...
taskExecutorCustomizers
)
{
Assert
.
notNull
(
taskExecutorCustomizers
,
"TaskExecutorCustomizers must not be null"
);
return
customizers
(
Arrays
.
asList
(
taskExecutorCustomizers
));
public
TaskExecutorBuilder
customizers
(
TaskExecutorCustomizer
...
customizers
)
{
Assert
.
notNull
(
customizers
,
"Customizers must not be null"
);
return
customizers
(
Arrays
.
asList
(
customizers
));
}
/**
...
...
@@ -197,52 +191,46 @@ public class TaskExecutorBuilder {
* applied to the {@link ThreadPoolTaskExecutor}. Customizers are applied in the order
* that they were added after builder configuration has been applied. Setting this
* value will replace any previously configured customizers.
* @param
taskExecutorC
ustomizers the customizers to set
* @param
c
ustomizers the customizers to set
* @return a new builder instance
* @see #additionalCustomizers(TaskExecutorCustomizer...)
*/
public
TaskExecutorBuilder
customizers
(
Collection
<?
extends
TaskExecutorCustomizer
>
taskExecutorCustomizers
)
{
Assert
.
notNull
(
taskExecutorCustomizers
,
"TaskExecutorCustomizers must not be null"
);
public
TaskExecutorBuilder
customizers
(
Iterable
<
TaskExecutorCustomizer
>
customizers
)
{
Assert
.
notNull
(
customizers
,
"Customizers must not be null"
);
return
new
TaskExecutorBuilder
(
this
.
queueCapacity
,
this
.
corePoolSize
,
this
.
maxPoolSize
,
this
.
allowCoreThreadTimeOut
,
this
.
keepAlive
,
this
.
threadNamePrefix
,
this
.
taskDecorator
,
Collections
.
unmodifiableSet
(
new
LinkedHashSet
<
TaskExecutorCustomizer
>(
taskExecutorCustomizers
)));
this
.
threadNamePrefix
,
this
.
taskDecorator
,
append
(
null
,
customizers
));
}
/**
* Add {@link TaskExecutorCustomizer TaskExecutorCustomizers} that should be applied
* to the {@link ThreadPoolTaskExecutor}. Customizers are applied in the order that
* they were added after builder configuration has been applied.
* @param
taskExecutorC
ustomizers the customizers to add
* @param
c
ustomizers the customizers to add
* @return a new builder instance
* @see #customizers(TaskExecutorCustomizer...)
*/
public
TaskExecutorBuilder
additionalCustomizers
(
TaskExecutorCustomizer
...
taskExecutorCustomizers
)
{
Assert
.
notNull
(
taskExecutorCustomizers
,
"TaskExecutorCustomizers must not be null"
);
return
additionalCustomizers
(
Arrays
.
asList
(
taskExecutorCustomizers
));
TaskExecutorCustomizer
...
customizers
)
{
Assert
.
notNull
(
customizers
,
"Customizers must not be null"
);
return
additionalCustomizers
(
Arrays
.
asList
(
customizers
));
}
/**
* Add {@link TaskExecutorCustomizer TaskExecutorCustomizers} that should be applied
* to the {@link ThreadPoolTaskExecutor}. Customizers are applied in the order that
* they were added after builder configuration has been applied.
* @param
taskExecutorC
ustomizers the customizers to add
* @param
c
ustomizers the customizers to add
* @return a new builder instance
* @see #customizers(TaskExecutorCustomizer...)
*/
public
TaskExecutorBuilder
additionalCustomizers
(
Collection
<?
extends
TaskExecutorCustomizer
>
taskExecutorCustomizers
)
{
Assert
.
notNull
(
taskExecutorCustomizers
,
"TaskExecutorCustomizers must not be null"
);
Iterable
<
TaskExecutorCustomizer
>
customizers
)
{
Assert
.
notNull
(
customizers
,
"Customizers must not be null"
);
return
new
TaskExecutorBuilder
(
this
.
queueCapacity
,
this
.
corePoolSize
,
this
.
maxPoolSize
,
this
.
allowCoreThreadTimeOut
,
this
.
keepAlive
,
this
.
threadNamePrefix
,
this
.
taskDecorator
,
append
(
this
.
taskExecutorCustomizers
,
taskExecutorC
ustomizers
));
append
(
this
.
customizers
,
c
ustomizers
));
}
/**
...
...
@@ -288,18 +276,15 @@ public class TaskExecutorBuilder {
map
.
from
(
this
.
threadNamePrefix
).
whenHasText
()
.
to
(
taskExecutor:
:
setThreadNamePrefix
);
map
.
from
(
this
.
taskDecorator
).
to
(
taskExecutor:
:
setTaskDecorator
);
if
(!
CollectionUtils
.
isEmpty
(
this
.
taskExecutorCustomizers
))
{
for
(
TaskExecutorCustomizer
customizer
:
this
.
taskExecutorCustomizers
)
{
customizer
.
customize
(
taskExecutor
);
}
if
(!
CollectionUtils
.
isEmpty
(
this
.
customizers
))
{
this
.
customizers
.
forEach
((
customizer
)
->
customizer
.
customize
(
taskExecutor
));
}
return
taskExecutor
;
}
private
static
<
T
>
Set
<
T
>
append
(
Set
<
T
>
set
,
Collection
<?
extends
T
>
additions
)
{
private
<
T
>
Set
<
T
>
append
(
Set
<
T
>
set
,
Iterable
<?
extends
T
>
additions
)
{
Set
<
T
>
result
=
new
LinkedHashSet
<>((
set
!=
null
)
?
set
:
Collections
.
emptySet
());
result
.
addAll
(
additions
);
additions
.
forEach
(
result:
:
add
);
return
Collections
.
unmodifiableSet
(
result
);
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/TaskSchedulerBuilder.java
View file @
c3de4c84
...
...
@@ -17,7 +17,6 @@
package
org
.
springframework
.
boot
.
task
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
...
...
@@ -45,22 +44,19 @@ public class TaskSchedulerBuilder {
private
final
String
threadNamePrefix
;
private
final
Set
<
TaskSchedulerCustomizer
>
taskSchedulerC
ustomizers
;
private
final
Set
<
TaskSchedulerCustomizer
>
c
ustomizers
;
public
TaskSchedulerBuilder
(
TaskSchedulerCustomizer
...
taskSchedulerCustomizers
)
{
Assert
.
notNull
(
taskSchedulerCustomizers
,
"TaskSchedulerCustomizers must not be null"
);
public
TaskSchedulerBuilder
()
{
this
.
poolSize
=
null
;
this
.
threadNamePrefix
=
null
;
this
.
taskSchedulerCustomizers
=
Collections
.
unmodifiableSet
(
new
LinkedHashSet
<>(
Arrays
.
asList
(
taskSchedulerCustomizers
)));
this
.
customizers
=
null
;
}
public
TaskSchedulerBuilder
(
Integer
poolSize
,
String
threadNamePrefix
,
Set
<
TaskSchedulerCustomizer
>
taskSchedulerCustomizers
)
{
this
.
poolSize
=
poolSize
;
this
.
threadNamePrefix
=
threadNamePrefix
;
this
.
taskSchedulerC
ustomizers
=
taskSchedulerCustomizers
;
this
.
c
ustomizers
=
taskSchedulerCustomizers
;
}
/**
...
...
@@ -70,7 +66,7 @@ public class TaskSchedulerBuilder {
*/
public
TaskSchedulerBuilder
poolSize
(
int
poolSize
)
{
return
new
TaskSchedulerBuilder
(
poolSize
,
this
.
threadNamePrefix
,
this
.
taskSchedulerC
ustomizers
);
this
.
c
ustomizers
);
}
/**
...
...
@@ -80,7 +76,7 @@ public class TaskSchedulerBuilder {
*/
public
TaskSchedulerBuilder
threadNamePrefix
(
String
threadNamePrefix
)
{
return
new
TaskSchedulerBuilder
(
this
.
poolSize
,
threadNamePrefix
,
this
.
taskSchedulerC
ustomizers
);
this
.
c
ustomizers
);
}
/**
...
...
@@ -88,15 +84,13 @@ public class TaskSchedulerBuilder {
* applied to the {@link ThreadPoolTaskScheduler}. Customizers are applied in the
* order that they were added after builder configuration has been applied. Setting
* this value will replace any previously configured customizers.
* @param
taskSchedulerC
ustomizers the customizers to set
* @param
c
ustomizers the customizers to set
* @return a new builder instance
* @see #additionalCustomizers(TaskSchedulerCustomizer...)
*/
public
TaskSchedulerBuilder
customizers
(
TaskSchedulerCustomizer
...
taskSchedulerCustomizers
)
{
Assert
.
notNull
(
taskSchedulerCustomizers
,
"TaskSchedulerCustomizers must not be null"
);
return
customizers
(
Arrays
.
asList
(
taskSchedulerCustomizers
));
public
TaskSchedulerBuilder
customizers
(
TaskSchedulerCustomizer
...
customizers
)
{
Assert
.
notNull
(
customizers
,
"Customizers must not be null"
);
return
customizers
(
Arrays
.
asList
(
customizers
));
}
/**
...
...
@@ -104,48 +98,44 @@ public class TaskSchedulerBuilder {
* applied to the {@link ThreadPoolTaskScheduler}. Customizers are applied in the
* order that they were added after builder configuration has been applied. Setting
* this value will replace any previously configured customizers.
* @param
taskSchedulerC
ustomizers the customizers to set
* @param
c
ustomizers the customizers to set
* @return a new builder instance
* @see #additionalCustomizers(TaskSchedulerCustomizer...)
*/
public
TaskSchedulerBuilder
customizers
(
Collection
<?
extends
TaskSchedulerCustomizer
>
taskSchedulerCustomizers
)
{
Assert
.
notNull
(
taskSchedulerCustomizers
,
"TaskSchedulerCustomizers must not be null"
);
Iterable
<
TaskSchedulerCustomizer
>
customizers
)
{
Assert
.
notNull
(
customizers
,
"Customizers must not be null"
);
return
new
TaskSchedulerBuilder
(
this
.
poolSize
,
this
.
threadNamePrefix
,
Collections
.
unmodifiableSet
(
new
LinkedHashSet
<
TaskSchedulerCustomizer
>(
taskSchedulerCustomizers
)));
append
(
null
,
customizers
));
}
/**
* Add {@link TaskSchedulerCustomizer taskSchedulerCustomizers} that should be applied
* to the {@link ThreadPoolTaskScheduler}. Customizers are applied in the order that
* they were added after builder configuration has been applied.
* @param
taskSchedulerC
ustomizers the customizers to add
* @param
c
ustomizers the customizers to add
* @return a new builder instance
* @see #customizers(TaskSchedulerCustomizer...)
*/
public
TaskSchedulerBuilder
additionalCustomizers
(
TaskSchedulerCustomizer
...
taskSchedulerCustomizers
)
{
Assert
.
notNull
(
taskSchedulerCustomizers
,
"TaskSchedulerCustomizers must not be null"
);
return
additionalCustomizers
(
Arrays
.
asList
(
taskSchedulerCustomizers
));
TaskSchedulerCustomizer
...
customizers
)
{
Assert
.
notNull
(
customizers
,
"Customizers must not be null"
);
return
additionalCustomizers
(
Arrays
.
asList
(
customizers
));
}
/**
* Add {@link TaskSchedulerCustomizer taskSchedulerCustomizers} that should be applied
* to the {@link ThreadPoolTaskScheduler}. Customizers are applied in the order that
* they were added after builder configuration has been applied.
* @param
taskSchedulerC
ustomizers the customizers to add
* @param
c
ustomizers the customizers to add
* @return a new builder instance
* @see #customizers(TaskSchedulerCustomizer...)
*/
public
TaskSchedulerBuilder
additionalCustomizers
(
Collection
<?
extends
TaskSchedulerCustomizer
>
taskSchedulerCustomizers
)
{
Assert
.
notNull
(
taskSchedulerCustomizers
,
"TaskSchedulerCustomizers must not be null"
);
Iterable
<
TaskSchedulerCustomizer
>
customizers
)
{
Assert
.
notNull
(
customizers
,
"Customizers must not be null"
);
return
new
TaskSchedulerBuilder
(
this
.
poolSize
,
this
.
threadNamePrefix
,
append
(
this
.
taskSchedulerCustomizers
,
taskSchedulerC
ustomizers
));
append
(
this
.
customizers
,
c
ustomizers
));
}
/**
...
...
@@ -169,18 +159,15 @@ public class TaskSchedulerBuilder {
PropertyMapper
map
=
PropertyMapper
.
get
().
alwaysApplyingWhenNonNull
();
map
.
from
(
this
.
poolSize
).
to
(
taskScheduler:
:
setPoolSize
);
map
.
from
(
this
.
threadNamePrefix
).
to
(
taskScheduler:
:
setThreadNamePrefix
);
if
(!
CollectionUtils
.
isEmpty
(
this
.
taskSchedulerCustomizers
))
{
for
(
TaskSchedulerCustomizer
customizer
:
this
.
taskSchedulerCustomizers
)
{
customizer
.
customize
(
taskScheduler
);
}
if
(!
CollectionUtils
.
isEmpty
(
this
.
customizers
))
{
this
.
customizers
.
forEach
((
customizer
)
->
customizer
.
customize
(
taskScheduler
));
}
return
taskScheduler
;
}
private
static
<
T
>
Set
<
T
>
append
(
Set
<
T
>
set
,
Collection
<?
extends
T
>
additions
)
{
private
<
T
>
Set
<
T
>
append
(
Set
<
T
>
set
,
Iterable
<?
extends
T
>
additions
)
{
Set
<
T
>
result
=
new
LinkedHashSet
<>((
set
!=
null
)
?
set
:
Collections
.
emptySet
());
result
.
addAll
(
additions
);
additions
.
forEach
(
result:
:
add
);
return
Collections
.
unmodifiableSet
(
result
);
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskExecutorBuilderTests.java
View file @
c3de4c84
...
...
@@ -47,13 +47,6 @@ public class TaskExecutorBuilderTests {
private
TaskExecutorBuilder
builder
=
new
TaskExecutorBuilder
();
@Test
public
void
createWhenCustomizersAreNullShouldThrowException
()
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"TaskExecutorCustomizers must not be null"
);
new
TaskExecutorBuilder
((
TaskExecutorCustomizer
[])
null
);
}
@Test
public
void
poolSettingsShouldApply
()
{
ThreadPoolTaskExecutor
executor
=
this
.
builder
.
queueCapacity
(
10
).
corePoolSize
(
4
)
...
...
@@ -85,14 +78,14 @@ public class TaskExecutorBuilderTests {
@Test
public
void
customizersWhenCustomizersAreNullShouldThrowException
()
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"
TaskExecutor
Customizers must not be null"
);
this
.
thrown
.
expectMessage
(
"Customizers must not be null"
);
this
.
builder
.
customizers
((
TaskExecutorCustomizer
[])
null
);
}
@Test
public
void
customizersCollectionWhenCustomizersAreNullShouldThrowException
()
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"
TaskExecutor
Customizers must not be null"
);
this
.
thrown
.
expectMessage
(
"Customizers must not be null"
);
this
.
builder
.
customizers
((
Set
<
TaskExecutorCustomizer
>)
null
);
}
...
...
@@ -135,14 +128,14 @@ public class TaskExecutorBuilderTests {
@Test
public
void
additionalCustomizersWhenCustomizersAreNullShouldThrowException
()
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"
TaskExecutor
Customizers must not be null"
);
this
.
thrown
.
expectMessage
(
"Customizers must not be null"
);
this
.
builder
.
additionalCustomizers
((
TaskExecutorCustomizer
[])
null
);
}
@Test
public
void
additionalCustomizersCollectionWhenCustomizersAreNullShouldThrowException
()
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"
TaskExecutor
Customizers must not be null"
);
this
.
thrown
.
expectMessage
(
"Customizers must not be null"
);
this
.
builder
.
additionalCustomizers
((
Set
<
TaskExecutorCustomizer
>)
null
);
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/task/TaskSchedulerBuilderTests.java
View file @
c3de4c84
...
...
@@ -43,13 +43,6 @@ public class TaskSchedulerBuilderTests {
private
TaskSchedulerBuilder
builder
=
new
TaskSchedulerBuilder
();
@Test
public
void
createWhenCustomizersAreNullShouldThrowException
()
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"TaskSchedulerCustomizers must not be null"
);
new
TaskSchedulerBuilder
((
TaskSchedulerCustomizer
[])
null
);
}
@Test
public
void
poolSettingsShouldApply
()
{
ThreadPoolTaskScheduler
scheduler
=
this
.
builder
.
poolSize
(
4
).
build
();
...
...
@@ -66,14 +59,14 @@ public class TaskSchedulerBuilderTests {
@Test
public
void
customizersWhenCustomizersAreNullShouldThrowException
()
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"
TaskScheduler
Customizers must not be null"
);
this
.
thrown
.
expectMessage
(
"Customizers must not be null"
);
this
.
builder
.
customizers
((
TaskSchedulerCustomizer
[])
null
);
}
@Test
public
void
customizersCollectionWhenCustomizersAreNullShouldThrowException
()
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"
TaskScheduler
Customizers must not be null"
);
this
.
thrown
.
expectMessage
(
"Customizers must not be null"
);
this
.
builder
.
customizers
((
Set
<
TaskSchedulerCustomizer
>)
null
);
}
...
...
@@ -108,14 +101,14 @@ public class TaskSchedulerBuilderTests {
@Test
public
void
additionalCustomizersWhenCustomizersAreNullShouldThrowException
()
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"
TaskScheduler
Customizers must not be null"
);
this
.
thrown
.
expectMessage
(
"Customizers must not be null"
);
this
.
builder
.
additionalCustomizers
((
TaskSchedulerCustomizer
[])
null
);
}
@Test
public
void
additionalCustomizersCollectionWhenCustomizersAreNullShouldThrowException
()
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"
TaskScheduler
Customizers must not be null"
);
this
.
thrown
.
expectMessage
(
"Customizers must not be null"
);
this
.
builder
.
additionalCustomizers
((
Set
<
TaskSchedulerCustomizer
>)
null
);
}
...
...
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