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
54c0cf51
Commit
54c0cf51
authored
Jan 17, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
3904f49c
Changes
93
Hide whitespace changes
Inline
Side-by-side
Showing
93 changed files
with
455 additions
and
435 deletions
+455
-435
CloudFoundryEndpointFilter.java
...utoconfigure/cloudfoundry/CloudFoundryEndpointFilter.java
+0
-1
CloudFoundryReactiveHealthEndpointWebExtension.java
...ctive/CloudFoundryReactiveHealthEndpointWebExtension.java
+2
-2
ReactiveCloudFoundryActuatorAutoConfiguration.java
...active/ReactiveCloudFoundryActuatorAutoConfiguration.java
+1
-2
CloudFoundryActuatorAutoConfiguration.java
...oundry/servlet/CloudFoundryActuatorAutoConfiguration.java
+2
-1
WebFluxEndpointManagementContextConfiguration.java
...active/WebFluxEndpointManagementContextConfiguration.java
+3
-2
DatadogProperties.java
...toconfigure/metrics/export/datadog/DatadogProperties.java
+4
-4
DatadogPropertiesConfigAdapter.java
...etrics/export/datadog/DatadogPropertiesConfigAdapter.java
+4
-4
InfluxProperties.java
...autoconfigure/metrics/export/influx/InfluxProperties.java
+3
-3
InfluxPropertiesConfigAdapter.java
.../metrics/export/influx/InfluxPropertiesConfigAdapter.java
+3
-4
StatsdProperties.java
...autoconfigure/metrics/export/statsd/StatsdProperties.java
+3
-3
EndpointRequest.java
...uate/autoconfigure/security/reactive/EndpointRequest.java
+12
-8
ExposeExcludePropertyEndpointFilterTests.java
...re/endpoint/ExposeExcludePropertyEndpointFilterTests.java
+3
-3
AbstractEndpointDocumentationTests.java
...web/documentation/AbstractEndpointDocumentationTests.java
+1
-1
LiquibaseEndpointDocumentationTests.java
...eb/documentation/LiquibaseEndpointDocumentationTests.java
+3
-5
LoggersEndpointDocumentationTests.java
.../web/documentation/LoggersEndpointDocumentationTests.java
+1
-2
MetricsEndpointDocumentationTests.java
.../web/documentation/MetricsEndpointDocumentationTests.java
+1
-2
WebFluxEndpointCorsIntegrationTests.java
.../integrationtest/WebFluxEndpointCorsIntegrationTests.java
+35
-49
LogFileWebEndpointAutoConfigurationTests.java
...ure/logging/LogFileWebEndpointAutoConfigurationTests.java
+2
-3
HeapDumpWebEndpointAutoConfigurationTests.java
...management/HeapDumpWebEndpointAutoConfigurationTests.java
+2
-3
CacheMetricsConfigurationTests.java
...nfigure/metrics/cache/CacheMetricsConfigurationTests.java
+6
-9
RestTemplateMetricsConfigurationTests.java
...ics/web/client/RestTemplateMetricsConfigurationTests.java
+5
-5
EndpointRequestTests.java
...autoconfigure/security/reactive/EndpointRequestTests.java
+15
-7
EndpointMBean.java
...ingframework/boot/actuate/endpoint/jmx/EndpointMBean.java
+2
-3
EndpointMBeanInfoAssembler.java
...boot/actuate/endpoint/jmx/EndpointMBeanInfoAssembler.java
+2
-3
EndpointLinksResolver.java
...work/boot/actuate/endpoint/web/EndpointLinksResolver.java
+2
-3
AbstractWebFluxEndpointHandlerMapping.java
...t/web/reactive/AbstractWebFluxEndpointHandlerMapping.java
+2
-3
AbstractWebMvcEndpointHandlerMapping.java
...int/web/servlet/AbstractWebMvcEndpointHandlerMapping.java
+2
-3
MetricsEndpoint.java
...springframework/boot/actuate/metrics/MetricsEndpoint.java
+1
-2
WebMvcMetricsFilterTests.java
...actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java
+3
-2
GsonProperties.java
...ringframework/boot/autoconfigure/gson/GsonProperties.java
+2
-2
GsonHttpMessageConvertersConfiguration.java
...onfigure/http/GsonHttpMessageConvertersConfiguration.java
+3
-2
SessionProperties.java
...amework/boot/autoconfigure/session/SessionProperties.java
+3
-2
JettyCustomizer.java
...oot/autoconfigure/web/embedded/jetty/JettyCustomizer.java
+7
-12
TomcatCustomizer.java
...t/autoconfigure/web/embedded/tomcat/TomcatCustomizer.java
+11
-11
UndertowCustomizer.java
...toconfigure/web/embedded/undertow/UndertowCustomizer.java
+8
-11
DefaultReactiveWebServerFactoryCustomizer.java
...b/reactive/DefaultReactiveWebServerFactoryCustomizer.java
+3
-2
AbstractErrorWebExceptionHandler.java
.../web/reactive/error/AbstractErrorWebExceptionHandler.java
+2
-1
DefaultErrorAttributes.java
...oconfigure/web/reactive/error/DefaultErrorAttributes.java
+2
-2
WebMvcAutoConfiguration.java
...ot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java
+12
-11
WebMvcProperties.java
...work/boot/autoconfigure/web/servlet/WebMvcProperties.java
+13
-12
WebSocketMessagingAutoConfiguration.java
...ebsocket/servlet/WebSocketMessagingAutoConfiguration.java
+2
-9
CacheAutoConfigurationTests.java
...boot/autoconfigure/cache/CacheAutoConfigurationTests.java
+2
-4
MongoRepositoriesAutoConfigurationTests.java
...e/data/mongo/MongoRepositoriesAutoConfigurationTests.java
+3
-3
DataSourceInitializerInvokerTests.java
...autoconfigure/jdbc/DataSourceInitializerInvokerTests.java
+2
-3
MailSenderAutoConfigurationTests.java
.../autoconfigure/mail/MailSenderAutoConfigurationTests.java
+2
-3
SecurityFilterAutoConfigurationEarlyInitializationTests.java
...urityFilterAutoConfigurationEarlyInitializationTests.java
+3
-2
SessionAutoConfigurationTests.java
.../autoconfigure/session/SessionAutoConfigurationTests.java
+13
-13
DefaultReactiveWebServerFactoryCustomizerTests.java
...ctive/DefaultReactiveWebServerFactoryCustomizerTests.java
+20
-10
ReactiveWebServerAutoConfigurationTests.java
...web/reactive/ReactiveWebServerAutoConfigurationTests.java
+4
-3
DefaultErrorWebExceptionHandlerIntegrationTests.java
...rror/DefaultErrorWebExceptionHandlerIntegrationTests.java
+1
-2
WebMvcAutoConfigurationTests.java
...toconfigure/web/servlet/WebMvcAutoConfigurationTests.java
+33
-22
WelcomePageHandlerMappingTests.java
...configure/web/servlet/WelcomePageHandlerMappingTests.java
+3
-2
WebSocketMessagingAutoConfigurationTests.java
...ket/servlet/WebSocketMessagingAutoConfigurationTests.java
+3
-3
GenericBomAstTransformation.java
...mework/boot/cli/compiler/GenericBomAstTransformation.java
+3
-3
UserServiceAutoConfiguration.java
...work/boot/autoconfigure/UserServiceAutoConfiguration.java
+1
-2
RandomPortWebTestClientExampleTests.java
...rk/boot/test/web/RandomPortWebTestClientExampleTests.java
+1
-4
SimpleTwoDataSourcesExampleTests.java
...framework/boot/jdbc/SimpleTwoDataSourcesExampleTests.java
+5
-3
AbstractJsonMarshalTester.java
...ngframework/boot/test/json/AbstractJsonMarshalTester.java
+2
-3
TestRestTemplateTests.java
...framework/boot/test/web/client/TestRestTemplateTests.java
+2
-3
ConfigurationMetadataRepositoryJsonBuilder.java
...nmetadata/ConfigurationMetadataRepositoryJsonBuilder.java
+5
-4
JSONArray.java
...framework/boot/configurationprocessor/json/JSONArray.java
+2
-2
JSONObject.java
...ramework/boot/configurationprocessor/json/JSONObject.java
+2
-2
JSONStringer.java
...mework/boot/configurationprocessor/json/JSONStringer.java
+1
-1
TypeUtils.java
...pringframework/boot/configurationprocessor/TypeUtils.java
+2
-3
JsonMarshaller.java
.../boot/configurationprocessor/metadata/JsonMarshaller.java
+2
-1
TestProject.java
...ingframework/boot/configurationprocessor/TestProject.java
+2
-3
JavaPluginAction.java
.../springframework/boot/gradle/plugin/JavaPluginAction.java
+1
-0
TestJarFile.java
...va/org/springframework/boot/loader/tools/TestJarFile.java
+2
-3
SystemPropertyUtils.java
...springframework/boot/loader/util/SystemPropertyUtils.java
+3
-3
RandomAccessDataFileTests.java
...framework/boot/loader/data/RandomAccessDataFileTests.java
+4
-4
PropertyMapper.java
...ringframework/boot/context/properties/PropertyMapper.java
+3
-3
Binder.java
.../springframework/boot/context/properties/bind/Binder.java
+3
-3
DurationConverter.java
...ot/context/properties/bind/convert/DurationConverter.java
+5
-3
ApplicationContextServerWebExchangeMatcher.java
.../reactive/ApplicationContextServerWebExchangeMatcher.java
+4
-4
JettyReactiveWebServerFactory.java
...oot/web/embedded/jetty/JettyReactiveWebServerFactory.java
+2
-2
JettyServletWebServerFactory.java
...boot/web/embedded/jetty/JettyServletWebServerFactory.java
+2
-3
TomcatReactiveWebServerFactory.java
...t/web/embedded/tomcat/TomcatReactiveWebServerFactory.java
+2
-3
TomcatWebServer.java
...ngframework/boot/web/embedded/tomcat/TomcatWebServer.java
+2
-2
UndertowCompressionConfigurer.java
.../web/embedded/undertow/UndertowCompressionConfigurer.java
+2
-1
UndertowReactiveWebServerFactory.java
...b/embedded/undertow/UndertowReactiveWebServerFactory.java
+10
-7
UndertowServletWebServerFactory.java
...eb/embedded/undertow/UndertowServletWebServerFactory.java
+1
-0
UndertowWebServer.java
...amework/boot/web/embedded/undertow/UndertowWebServer.java
+3
-2
AnnotationConfigReactiveWebServerApplicationContext.java
.../AnnotationConfigReactiveWebServerApplicationContext.java
+3
-3
DynamicRegistrationBean.java
...ngframework/boot/web/servlet/DynamicRegistrationBean.java
+2
-2
ServletContextInitializerBeans.java
...work/boot/web/servlet/ServletContextInitializerBeans.java
+2
-2
AnnotationConfigServletWebServerApplicationContext.java
...t/AnnotationConfigServletWebServerApplicationContext.java
+4
-2
SessionStoreDirectory.java
...mework/boot/web/servlet/server/SessionStoreDirectory.java
+3
-2
ExitCodeGeneratorsTests.java
...ava/org/springframework/boot/ExitCodeGeneratorsTests.java
+2
-3
DurationConverterTests.java
...ntext/properties/bind/convert/DurationConverterTests.java
+3
-2
LiquibaseServiceLocatorApplicationListenerTests.java
...base/LiquibaseServiceLocatorApplicationListenerTests.java
+4
-3
ApplicationContextServerWebExchangeMatcherTests.java
...tive/ApplicationContextServerWebExchangeMatcherTests.java
+23
-15
AbstractReactiveWebServerFactoryTests.java
...eactive/server/AbstractReactiveWebServerFactoryTests.java
+47
-34
AbstractServletWebServerFactoryTests.java
.../servlet/server/AbstractServletWebServerFactoryTests.java
+1
-1
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryEndpointFilter.java
View file @
54c0cf51
...
...
@@ -36,4 +36,3 @@ class CloudFoundryEndpointFilter implements EndpointFilter<WebOperation> {
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundryReactiveHealthEndpointWebExtension.java
View file @
54c0cf51
...
...
@@ -27,8 +27,8 @@ import org.springframework.boot.actuate.health.HealthEndpoint;
import
org.springframework.boot.actuate.health.ReactiveHealthEndpointWebExtension
;
/**
* Reactive {@link EndpointExtension} for the {@link HealthEndpoint} that always
*
exposes
full health details.
* Reactive {@link EndpointExtension} for the {@link HealthEndpoint} that always
exposes
* full health details.
*
* @author Madhura Bhave
* @since 2.0.0
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java
View file @
54c0cf51
...
...
@@ -75,8 +75,7 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@ConditionalOnEnabledEndpoint
@ConditionalOnBean
({
HealthEndpoint
.
class
,
ReactiveHealthEndpointWebExtension
.
class
})
@ConditionalOnBean
({
HealthEndpoint
.
class
,
ReactiveHealthEndpointWebExtension
.
class
})
public
CloudFoundryReactiveHealthEndpointWebExtension
cloudFoundryReactiveHealthEndpointWebExtension
(
ReactiveHealthEndpointWebExtension
reactiveHealthEndpointWebExtension
)
{
return
new
CloudFoundryReactiveHealthEndpointWebExtension
(
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java
View file @
54c0cf51
...
...
@@ -60,7 +60,8 @@ import org.springframework.web.servlet.DispatcherServlet;
*/
@Configuration
@ConditionalOnProperty
(
prefix
=
"management.cloudfoundry"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
@AutoConfigureAfter
({
ServletManagementContextAutoConfiguration
.
class
,
HealthEndpointAutoConfiguration
.
class
})
@AutoConfigureAfter
({
ServletManagementContextAutoConfiguration
.
class
,
HealthEndpointAutoConfiguration
.
class
})
@ConditionalOnWebApplication
(
type
=
ConditionalOnWebApplication
.
Type
.
SERVLET
)
@ConditionalOnClass
(
DispatcherServlet
.
class
)
@ConditionalOnBean
(
DispatcherServlet
.
class
)
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/reactive/WebFluxEndpointManagementContextConfiguration.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -56,7 +56,8 @@ public class WebFluxEndpointManagementContextConfiguration {
WebEndpointProperties
webEndpointProperties
)
{
return
new
WebFluxEndpointHandlerMapping
(
new
EndpointMapping
(
webEndpointProperties
.
getBasePath
()),
endpointDiscoverer
.
discoverEndpoints
(),
endpointMediaTypes
,
corsProperties
.
toCorsConfiguration
());
endpointDiscoverer
.
discoverEndpoints
(),
endpointMediaTypes
,
corsProperties
.
toCorsConfiguration
());
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/datadog/DatadogProperties.java
View file @
54c0cf51
...
...
@@ -34,8 +34,8 @@ public class DatadogProperties extends StepRegistryProperties {
private
String
apiKey
;
/**
* Datadog application key. Not strictly required, but improves the Datadog
*
experience
by sending meter descriptions, types, and base units to Datadog.
* Datadog application key. Not strictly required, but improves the Datadog
experience
* by sending meter descriptions, types, and base units to Datadog.
*/
private
String
applicationKey
;
...
...
@@ -46,8 +46,8 @@ public class DatadogProperties extends StepRegistryProperties {
private
Boolean
descriptions
;
/**
* Tag that will be mapped to "host" when shipping metrics to Datadog. Can be
*
omitted
if host should be omitted on publishing.
* Tag that will be mapped to "host" when shipping metrics to Datadog. Can be
omitted
* if host should be omitted on publishing.
*/
private
String
hostTag
;
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/datadog/DatadogPropertiesConfigAdapter.java
View file @
54c0cf51
...
...
@@ -26,9 +26,8 @@ import org.springframework.boot.actuate.autoconfigure.metrics.export.StepRegistr
* @author Jon Schneider
* @author Phillip Webb
*/
class
DatadogPropertiesConfigAdapter
extends
StepRegistryPropertiesConfigAdapter
<
DatadogProperties
>
implements
DatadogConfig
{
class
DatadogPropertiesConfigAdapter
extends
StepRegistryPropertiesConfigAdapter
<
DatadogProperties
>
implements
DatadogConfig
{
DatadogPropertiesConfigAdapter
(
DatadogProperties
properties
)
{
super
(
properties
);
...
...
@@ -41,7 +40,8 @@ class DatadogPropertiesConfigAdapter
@Override
public
String
applicationKey
()
{
return
get
(
DatadogProperties:
:
getApplicationKey
,
DatadogConfig
.
super
::
applicationKey
);
return
get
(
DatadogProperties:
:
getApplicationKey
,
DatadogConfig
.
super
::
applicationKey
);
}
@Override
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -31,8 +31,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
public
class
InfluxProperties
extends
StepRegistryProperties
{
/**
* Tag that will be mapped to "host" when shipping metrics to Influx. Can be
*
omitted
if host should be omitted on publishing.
* Tag that will be mapped to "host" when shipping metrics to Influx. Can be
omitted
* if host should be omitted on publishing.
*/
private
String
db
;
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxPropertiesConfigAdapter.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -27,9 +27,8 @@ import org.springframework.boot.actuate.autoconfigure.metrics.export.StepRegistr
* @author Jon Schneider
* @author Phillip Webb
*/
class
InfluxPropertiesConfigAdapter
extends
StepRegistryPropertiesConfigAdapter
<
InfluxProperties
>
implements
InfluxConfig
{
class
InfluxPropertiesConfigAdapter
extends
StepRegistryPropertiesConfigAdapter
<
InfluxProperties
>
implements
InfluxConfig
{
InfluxPropertiesConfigAdapter
(
InfluxProperties
properties
)
{
super
(
properties
);
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -58,8 +58,8 @@ public class StatsdProperties {
private
Integer
maxPacketLength
=
1400
;
/**
* How often gauges will be polled. When a gauge is polled, its value is
*
recalculated
and if the value has changed, it is sent to the StatsD server.
* How often gauges will be polled. When a gauge is polled, its value is
recalculated
* and if the value has changed, it is sent to the StatsD server.
*/
private
Duration
pollingFrequency
=
Duration
.
ofSeconds
(
10
);
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -39,8 +39,8 @@ import org.springframework.util.Assert;
import
org.springframework.web.server.ServerWebExchange
;
/**
* Factory that can be used to create a {@link ServerWebExchangeMatcher} for actuator
endpoint
* locations.
* Factory that can be used to create a {@link ServerWebExchangeMatcher} for actuator
*
endpoint
locations.
*
* @author Madhura Bhave
* @since 2.0.0
...
...
@@ -52,8 +52,9 @@ public final class EndpointRequest {
/**
* Returns a matcher that includes all {@link Endpoint actuator endpoints}. The
* {@link EndpointServerWebExchangeMatcher#excluding(Class...) excluding} method can be used to
* further remove specific endpoints if required. For example: <pre class="code">
* {@link EndpointServerWebExchangeMatcher#excluding(Class...) excluding} method can
* be used to further remove specific endpoints if required. For example:
* <pre class="code">
* EndpointServerWebExchangeMatcher.toAnyEndpoint().excluding(ShutdownEndpoint.class)
* </pre>
* @return the configured {@link ServerWebExchangeMatcher}
...
...
@@ -87,7 +88,8 @@ public final class EndpointRequest {
}
/**
* The {@link ServerWebExchangeMatcher} used to match against {@link Endpoint actuator endpoints}.
* The {@link ServerWebExchangeMatcher} used to match against {@link Endpoint actuator
* endpoints}.
*/
public
final
static
class
EndpointServerWebExchangeMatcher
extends
ApplicationContextServerWebExchangeMatcher
<
EndpointPathProvider
>
{
...
...
@@ -116,7 +118,8 @@ public final class EndpointRequest {
this
.
excludes
=
Collections
.
emptyList
();
}
private
EndpointServerWebExchangeMatcher
(
List
<
Object
>
includes
,
List
<
Object
>
excludes
)
{
private
EndpointServerWebExchangeMatcher
(
List
<
Object
>
includes
,
List
<
Object
>
excludes
)
{
super
(
EndpointPathProvider
.
class
);
this
.
includes
=
includes
;
this
.
excludes
=
excludes
;
...
...
@@ -167,7 +170,8 @@ public final class EndpointRequest {
}
private
List
<
ServerWebExchangeMatcher
>
getDelegateMatchers
(
Set
<
String
>
paths
)
{
return
paths
.
stream
().
map
((
path
)
->
new
PathPatternParserServerWebExchangeMatcher
(
path
+
"/**"
))
return
paths
.
stream
().
map
(
(
path
)
->
new
PathPatternParserServerWebExchangeMatcher
(
path
+
"/**"
))
.
collect
(
Collectors
.
toList
());
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/ExposeExcludePropertyEndpointFilterTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -74,7 +74,7 @@ public class ExposeExcludePropertyEndpointFilterTests {
public
void
createWhenPrefixIsNullShouldThrowException
()
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"Prefix must not be empty"
);
new
ExposeExcludePropertyEndpointFilter
<
Operation
>(
TestEndpointDiscoverer
.
class
,
new
ExposeExcludePropertyEndpointFilter
<>(
TestEndpointDiscoverer
.
class
,
this
.
environment
,
null
);
}
...
...
@@ -82,7 +82,7 @@ public class ExposeExcludePropertyEndpointFilterTests {
public
void
createWhenPrefixIsEmptyShouldThrowException
()
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"Prefix must not be empty"
);
new
ExposeExcludePropertyEndpointFilter
<
Operation
>(
TestEndpointDiscoverer
.
class
,
new
ExposeExcludePropertyEndpointFilter
<>(
TestEndpointDiscoverer
.
class
,
this
.
environment
,
""
);
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java
View file @
54c0cf51
...
...
@@ -113,7 +113,7 @@ public class AbstractEndpointDocumentationTests {
@SuppressWarnings
(
"unchecked"
)
private
<
T
>
Map
<
String
,
Object
>
select
(
Map
<
String
,
Object
>
candidates
,
Predicate
<
T
>
filter
)
{
Map
<
String
,
Object
>
selected
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
selected
=
new
HashMap
<>();
candidates
.
entrySet
().
stream
().
filter
((
candidate
)
->
filter
.
test
((
T
)
candidate
))
.
limit
(
3
)
.
forEach
((
entry
)
->
selected
.
put
(
entry
.
getKey
(),
entry
.
getValue
()));
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LiquibaseEndpointDocumentationTests.java
View file @
54c0cf51
...
...
@@ -56,11 +56,9 @@ public class LiquibaseEndpointDocumentationTests
responseFields
(
fieldWithPath
(
"contexts"
)
.
description
(
"Application contexts keyed by id"
),
changeSetsField
)
.
andWithPrefix
(
"contexts.*.liquibaseBeans.*.changeSets[]."
,
getChangeSetFieldDescriptors
())
.
and
(
parentIdField
())));
changeSetsField
).
andWithPrefix
(
"contexts.*.liquibaseBeans.*.changeSets[]."
,
getChangeSetFieldDescriptors
()).
and
(
parentIdField
())));
}
private
List
<
FieldDescriptor
>
getChangeSetFieldDescriptors
()
{
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java
View file @
54c0cf51
...
...
@@ -48,8 +48,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Andy Wilkinson
*/
public
class
LoggersEndpointDocumentationTests
extends
MockMvcEndpointDocumentationTests
{
public
class
LoggersEndpointDocumentationTests
extends
MockMvcEndpointDocumentationTests
{
private
static
final
List
<
FieldDescriptor
>
levelFields
=
Arrays
.
asList
(
fieldWithPath
(
"configuredLevel"
)
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MetricsEndpointDocumentationTests.java
View file @
54c0cf51
...
...
@@ -39,8 +39,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Andy Wilkinson
*/
public
class
MetricsEndpointDocumentationTests
extends
MockMvcEndpointDocumentationTests
{
public
class
MetricsEndpointDocumentationTests
extends
MockMvcEndpointDocumentationTests
{
@Test
public
void
metricNames
()
throws
Exception
{
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebFluxEndpointCorsIntegrationTests.java
View file @
54c0cf51
...
...
@@ -48,9 +48,9 @@ public class WebFluxEndpointCorsIntegrationTests {
public
void
createContext
()
{
this
.
context
=
new
AnnotationConfigReactiveWebApplicationContext
();
this
.
context
.
register
(
JacksonAutoConfiguration
.
class
,
CodecsAutoConfiguration
.
class
,
WebFluxAutoConfiguration
.
class
,
HttpHandler
AutoConfiguration
.
class
,
EndpointAutoConfiguration
.
class
,
WebEndpointAutoConfiguration
.
class
,
CodecsAutoConfiguration
.
class
,
WebFluxAutoConfiguration
.
class
,
HttpHandlerAutoConfiguration
.
class
,
Endpoint
AutoConfiguration
.
class
,
WebEndpointAutoConfiguration
.
class
,
ManagementContextAutoConfiguration
.
class
,
ReactiveManagementContextAutoConfiguration
.
class
,
BeansEndpointAutoConfiguration
.
class
);
...
...
@@ -59,13 +59,11 @@ public class WebFluxEndpointCorsIntegrationTests {
@Test
public
void
corsIsDisabledByDefault
()
{
createWebTestClient
()
.
options
().
uri
(
"/actuator/beans"
)
createWebTestClient
().
options
().
uri
(
"/actuator/beans"
)
.
header
(
"Origin"
,
"spring.example.org"
)
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_METHOD
,
"GET"
)
.
exchange
()
.
expectStatus
().
isForbidden
()
.
expectHeader
().
doesNotExist
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_ORIGIN
);
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_METHOD
,
"GET"
).
exchange
()
.
expectStatus
().
isForbidden
().
expectHeader
()
.
doesNotExist
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_ORIGIN
);
}
@Test
...
...
@@ -73,11 +71,9 @@ public class WebFluxEndpointCorsIntegrationTests {
TestPropertyValues
.
of
(
"management.endpoints.web.cors.allowed-origins:spring.example.org"
)
.
applyTo
(
this
.
context
);
createWebTestClient
()
.
options
().
uri
(
"/actuator/beans"
)
createWebTestClient
().
options
().
uri
(
"/actuator/beans"
)
.
header
(
"Origin"
,
"test.example.org"
)
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_METHOD
,
"GET"
)
.
exchange
()
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_METHOD
,
"GET"
).
exchange
()
.
expectStatus
().
isForbidden
();
performAcceptedCorsRequest
(
"/actuator/beans"
);
}
...
...
@@ -87,8 +83,8 @@ public class WebFluxEndpointCorsIntegrationTests {
TestPropertyValues
.
of
(
"management.endpoints.web.cors.allowed-origins:spring.example.org"
)
.
applyTo
(
this
.
context
);
performAcceptedCorsRequest
(
"/actuator/beans"
)
.
expectHeader
().
valueEquals
(
HttpHeaders
.
ACCESS_CONTROL_MAX_AGE
,
"1800"
);
performAcceptedCorsRequest
(
"/actuator/beans"
)
.
expectHeader
()
.
valueEquals
(
HttpHeaders
.
ACCESS_CONTROL_MAX_AGE
,
"1800"
);
}
@Test
...
...
@@ -97,8 +93,8 @@ public class WebFluxEndpointCorsIntegrationTests {
.
of
(
"management.endpoints.web.cors.allowed-origins:spring.example.org"
,
"management.endpoints.web.cors.max-age: 2400"
)
.
applyTo
(
this
.
context
);
performAcceptedCorsRequest
(
"/actuator/beans"
)
.
expectHeader
().
valueEquals
(
HttpHeaders
.
ACCESS_CONTROL_MAX_AGE
,
"2400"
);
performAcceptedCorsRequest
(
"/actuator/beans"
)
.
expectHeader
()
.
valueEquals
(
HttpHeaders
.
ACCESS_CONTROL_MAX_AGE
,
"2400"
);
}
@Test
...
...
@@ -106,12 +102,10 @@ public class WebFluxEndpointCorsIntegrationTests {
TestPropertyValues
.
of
(
"management.endpoints.web.cors.allowed-origins:spring.example.org"
)
.
applyTo
(
this
.
context
);
createWebTestClient
()
.
options
().
uri
(
"/actuator/beans"
)
createWebTestClient
().
options
().
uri
(
"/actuator/beans"
)
.
header
(
"Origin"
,
"spring.example.org"
)
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_METHOD
,
"GET"
)
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_HEADERS
,
"Alpha"
)
.
exchange
()
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_HEADERS
,
"Alpha"
).
exchange
()
.
expectStatus
().
isForbidden
();
}
...
...
@@ -121,14 +115,12 @@ public class WebFluxEndpointCorsIntegrationTests {
.
of
(
"management.endpoints.web.cors.allowed-origins:spring.example.org"
,
"management.endpoints.web.cors.allowed-headers:Alpha,Bravo"
)
.
applyTo
(
this
.
context
);
createWebTestClient
()
.
options
().
uri
(
"/actuator/beans"
)
createWebTestClient
().
options
().
uri
(
"/actuator/beans"
)
.
header
(
"Origin"
,
"spring.example.org"
)
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_METHOD
,
"GET"
)
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_HEADERS
,
"Alpha"
)
.
exchange
()
.
expectStatus
().
isOk
()
.
expectHeader
().
valueEquals
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_HEADERS
,
"Alpha"
);
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_HEADERS
,
"Alpha"
).
exchange
()
.
expectStatus
().
isOk
().
expectHeader
()
.
valueEquals
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_HEADERS
,
"Alpha"
);
}
@Test
...
...
@@ -136,11 +128,9 @@ public class WebFluxEndpointCorsIntegrationTests {
TestPropertyValues
.
of
(
"management.endpoints.web.cors.allowed-origins:spring.example.org"
)
.
applyTo
(
this
.
context
);
createWebTestClient
()
.
options
().
uri
(
"/actuator/beans"
)
createWebTestClient
().
options
().
uri
(
"/actuator/beans"
)
.
header
(
"Origin"
,
"spring.example.org"
)
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_METHOD
,
"PATCH"
)
.
exchange
()
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_METHOD
,
"PATCH"
).
exchange
()
.
expectStatus
().
isForbidden
();
}
...
...
@@ -150,13 +140,11 @@ public class WebFluxEndpointCorsIntegrationTests {
.
of
(
"management.endpoints.web.cors.allowed-origins:spring.example.org"
,
"management.endpoints.web.cors.allowed-methods:GET,HEAD"
)
.
applyTo
(
this
.
context
);
createWebTestClient
()
.
options
().
uri
(
"/actuator/beans"
)
createWebTestClient
().
options
().
uri
(
"/actuator/beans"
)
.
header
(
"Origin"
,
"spring.example.org"
)
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_METHOD
,
"HEAD"
)
.
exchange
()
.
expectStatus
().
isOk
()
.
expectHeader
().
valueEquals
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_METHODS
,
"GET,HEAD"
);
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_METHOD
,
"HEAD"
).
exchange
()
.
expectStatus
().
isOk
().
expectHeader
()
.
valueEquals
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_METHODS
,
"GET,HEAD"
);
}
@Test
...
...
@@ -165,8 +153,8 @@ public class WebFluxEndpointCorsIntegrationTests {
.
of
(
"management.endpoints.web.cors.allowed-origins:spring.example.org"
,
"management.endpoints.web.cors.allow-credentials:true"
)
.
applyTo
(
this
.
context
);
performAcceptedCorsRequest
(
"/actuator/beans"
)
.
expectHeader
().
valueEquals
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_CREDENTIALS
,
"true"
);
performAcceptedCorsRequest
(
"/actuator/beans"
)
.
expectHeader
()
.
valueEquals
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_CREDENTIALS
,
"true"
);
}
@Test
...
...
@@ -175,24 +163,22 @@ public class WebFluxEndpointCorsIntegrationTests {
.
of
(
"management.endpoints.web.cors.allowed-origins:spring.example.org"
,
"management.endpoints.web.cors.allow-credentials:false"
)
.
applyTo
(
this
.
context
);
performAcceptedCorsRequest
(
"/actuator/beans"
)
.
expectHeader
().
doesNotExist
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_CREDENTIALS
);
performAcceptedCorsRequest
(
"/actuator/beans"
)
.
expectHeader
()
.
doesNotExist
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_CREDENTIALS
);
}
private
WebTestClient
createWebTestClient
()
{
this
.
context
.
refresh
();
return
WebTestClient
.
bindToApplicationContext
(
this
.
context
)
.
configureClient
().
baseUrl
(
"https://spring.example.org"
).
build
();
return
WebTestClient
.
bindToApplicationContext
(
this
.
context
)
.
configureClient
()
.
baseUrl
(
"https://spring.example.org"
).
build
();
}
private
WebTestClient
.
ResponseSpec
performAcceptedCorsRequest
(
String
url
)
{
return
createWebTestClient
()
.
options
().
uri
(
url
)
return
createWebTestClient
().
options
().
uri
(
url
)
.
header
(
HttpHeaders
.
ORIGIN
,
"spring.example.org"
)
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_METHOD
,
"GET"
)
.
ex
change
()
.
expectHeader
().
valueEquals
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_ORIGIN
,
"spring.example.org"
)
.
header
(
HttpHeaders
.
ACCESS_CONTROL_REQUEST_METHOD
,
"GET"
)
.
exchange
()
.
ex
pectHeader
().
valueEquals
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_ORIGIN
,
"spring.example.org"
)
.
expectStatus
().
isOk
();
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -45,8 +45,7 @@ public class LogFileWebEndpointAutoConfigurationTests {
public
TemporaryFolder
temp
=
new
TemporaryFolder
();
private
WebApplicationContextRunner
contextRunner
=
new
WebApplicationContextRunner
()
.
withUserConfiguration
(
LogFileWebEndpointAutoConfiguration
.
class
);
.
withUserConfiguration
(
LogFileWebEndpointAutoConfiguration
.
class
);
@Test
public
void
logFileWebEndpointIsAutoConfiguredWhenLoggingFileIsSet
()
{
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/management/HeapDumpWebEndpointAutoConfigurationTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -32,8 +32,7 @@ public class HeapDumpWebEndpointAutoConfigurationTests {
private
final
WebApplicationContextRunner
contextRunner
=
new
WebApplicationContextRunner
()
.
withPropertyValues
(
"management.endpoints.web.expose:*"
)
.
withUserConfiguration
(
HeapDumpWebEndpointAutoConfiguration
.
class
);
.
withUserConfiguration
(
HeapDumpWebEndpointAutoConfiguration
.
class
);
@Test
public
void
runShouldCreateIndicator
()
{
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsConfigurationTests.java
View file @
54c0cf51
...
...
@@ -39,15 +39,14 @@ public class CacheMetricsConfigurationTests {
private
final
ApplicationContextRunner
contextRunner
=
new
ApplicationContextRunner
()
.
withUserConfiguration
(
RegistryConfiguration
.
class
)
.
withConfiguration
(
AutoConfigurations
.
of
(
MetricsAutoConfiguration
.
class
,
CacheAutoConfiguration
.
class
))
.
withConfiguration
(
AutoConfigurations
.
of
(
MetricsAutoConfiguration
.
class
,
CacheAutoConfiguration
.
class
))
.
withPropertyValues
(
"management.metrics.use-global-registry=false"
);
@Test
public
void
autoConfiguredCacheManagerIsInstrumented
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.cache.type=caffeine"
,
"spring.cache.cache-names=cache1,cache2"
)
.
run
((
context
)
->
{
this
.
contextRunner
.
withPropertyValues
(
"spring.cache.type=caffeine"
,
"spring.cache.cache-names=cache1,cache2"
).
run
((
context
)
->
{
MeterRegistry
registry
=
context
.
getBean
(
MeterRegistry
.
class
);
assertThat
(
registry
.
find
(
"cache.requests"
).
tags
(
"name"
,
"cache1"
)
.
tags
(
"cacheManager"
,
"cacheManager"
).
meter
()).
isPresent
();
...
...
@@ -73,10 +72,8 @@ public class CacheMetricsConfigurationTests {
@Test
public
void
autoConfiguredNonSupportedCacheManagerIsIgnored
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.cache.type=simple"
,
"spring.cache.cache-names=cache1,cache2"
)
.
run
((
context
)
->
{
this
.
contextRunner
.
withPropertyValues
(
"spring.cache.type=simple"
,
"spring.cache.cache-names=cache1,cache2"
).
run
((
context
)
->
{
MeterRegistry
registry
=
context
.
getBean
(
MeterRegistry
.
class
);
assertThat
(
registry
.
find
(
"cache.requests"
).
tags
(
"name"
,
"cache1"
)
.
tags
(
"cacheManager"
,
"cacheManager"
).
meter
()).
isNotPresent
();
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsConfigurationTests.java
View file @
54c0cf51
...
...
@@ -45,11 +45,10 @@ public class RestTemplateMetricsConfigurationTests {
private
final
ApplicationContextRunner
contextRunner
=
new
ApplicationContextRunner
()
.
withPropertyValues
(
"management.metrics.use-global-registry=false"
)
.
withConfiguration
(
AutoConfigurations
.
of
(
RestTemplateAutoConfiguration
.
class
,
MetricsAutoConfiguration
.
class
))
.
withConfiguration
(
AutoConfigurations
.
of
(
RestTemplateAutoConfiguration
.
class
,
MetricsAutoConfiguration
.
class
))
.
withUserConfiguration
(
RegistryConfiguration
.
class
);
@Test
public
void
restTemplateCreatedWithBuilderIsInstrumented
()
{
this
.
contextRunner
.
run
((
context
)
->
{
...
...
@@ -64,8 +63,9 @@ public class RestTemplateMetricsConfigurationTests {
public
void
restTemplateCanBeCustomizedManually
()
{
this
.
contextRunner
.
run
((
context
)
->
{
assertThat
(
context
).
hasSingleBean
(
MetricsRestTemplateCustomizer
.
class
);
RestTemplate
restTemplate
=
new
RestTemplateBuilder
().
customizers
(
context
.
getBean
(
MetricsRestTemplateCustomizer
.
class
)).
build
();
RestTemplate
restTemplate
=
new
RestTemplateBuilder
()
.
customizers
(
context
.
getBean
(
MetricsRestTemplateCustomizer
.
class
))
.
build
();
MeterRegistry
registry
=
context
.
getBean
(
MeterRegistry
.
class
);
validateRestTemplate
(
restTemplate
,
registry
);
});
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequestTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -91,7 +91,8 @@ public class EndpointRequestTests {
@Test
public
void
excludeByIdShouldNotMatchExcluded
()
{
ServerWebExchangeMatcher
matcher
=
EndpointRequest
.
toAnyEndpoint
().
excluding
(
"foo"
);
ServerWebExchangeMatcher
matcher
=
EndpointRequest
.
toAnyEndpoint
()
.
excluding
(
"foo"
);
assertMatcher
(
matcher
).
doesNotMatch
(
"/actuator/foo"
);
assertMatcher
(
matcher
).
matches
(
"/actuator/bar"
);
}
...
...
@@ -113,13 +114,16 @@ public class EndpointRequestTests {
private
final
ServerWebExchangeMatcher
matcher
;
RequestMatcherAssert
(
StaticApplicationContext
context
,
ServerWebExchangeMatcher
matcher
)
{
RequestMatcherAssert
(
StaticApplicationContext
context
,
ServerWebExchangeMatcher
matcher
)
{
this
.
context
=
context
;
this
.
matcher
=
matcher
;
}
void
matches
(
String
path
)
{
ServerWebExchange
exchange
=
webHandler
().
createExchange
(
MockServerHttpRequest
.
get
(
path
).
build
(),
new
MockServerHttpResponse
());
ServerWebExchange
exchange
=
webHandler
().
createExchange
(
MockServerHttpRequest
.
get
(
path
).
build
(),
new
MockServerHttpResponse
());
matches
(
exchange
);
}
...
...
@@ -129,7 +133,9 @@ public class EndpointRequestTests {
}
void
doesNotMatch
(
String
path
)
{
ServerWebExchange
exchange
=
webHandler
().
createExchange
(
MockServerHttpRequest
.
get
(
path
).
build
(),
new
MockServerHttpResponse
());
ServerWebExchange
exchange
=
webHandler
().
createExchange
(
MockServerHttpRequest
.
get
(
path
).
build
(),
new
MockServerHttpResponse
());
doesNotMatch
(
exchange
);
}
...
...
@@ -139,7 +145,8 @@ public class EndpointRequestTests {
}
private
TestHttpWebHandlerAdapter
webHandler
()
{
TestHttpWebHandlerAdapter
adapter
=
new
TestHttpWebHandlerAdapter
(
mock
(
WebHandler
.
class
));
TestHttpWebHandlerAdapter
adapter
=
new
TestHttpWebHandlerAdapter
(
mock
(
WebHandler
.
class
));
adapter
.
setApplicationContext
(
this
.
context
);
return
adapter
;
}
...
...
@@ -157,7 +164,8 @@ public class EndpointRequestTests {
}
@Override
protected
ServerWebExchange
createExchange
(
ServerHttpRequest
request
,
ServerHttpResponse
response
)
{
protected
ServerWebExchange
createExchange
(
ServerHttpRequest
request
,
ServerHttpResponse
response
)
{
return
super
.
createExchange
(
request
,
response
);
}
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBean.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -76,8 +76,7 @@ public class EndpointMBean implements DynamicMBean {
@Override
public
Object
invoke
(
String
actionName
,
Object
[]
params
,
String
[]
signature
)
throws
MBeanException
,
ReflectionException
{
JmxOperation
operation
=
this
.
endpointInfo
.
getOperations
()
.
get
(
actionName
);
JmxOperation
operation
=
this
.
endpointInfo
.
getOperations
().
get
(
actionName
);
if
(
operation
!=
null
)
{
Map
<
String
,
Object
>
arguments
=
getArguments
(
params
,
operation
.
getParameters
());
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanInfoAssembler.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -53,8 +53,7 @@ class EndpointMBeanInfoAssembler {
* @param endpointInfo the endpoint to handle
* @return the mbean info for the endpoint
*/
EndpointMBeanInfo
createEndpointMBeanInfo
(
EndpointInfo
<
JmxOperation
>
endpointInfo
)
{
EndpointMBeanInfo
createEndpointMBeanInfo
(
EndpointInfo
<
JmxOperation
>
endpointInfo
)
{
Map
<
String
,
OperationInfos
>
operationsMapping
=
getOperationInfo
(
endpointInfo
);
ModelMBeanOperationInfo
[]
operationsMBeanInfo
=
operationsMapping
.
values
()
.
stream
().
map
((
t
)
->
t
.
mBeanOperationInfo
).
collect
(
Collectors
.
toList
())
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/EndpointLinksResolver.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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,8 +38,7 @@ public class EndpointLinksResolver {
* @return the links
*/
public
Map
<
String
,
Link
>
resolveLinks
(
Collection
<
EndpointInfo
<
WebOperation
>>
webEndpoints
,
String
requestUrl
)
{
Collection
<
EndpointInfo
<
WebOperation
>>
webEndpoints
,
String
requestUrl
)
{
String
normalizedUrl
=
normalizeRequestUrl
(
requestUrl
);
Map
<
String
,
Link
>
links
=
new
LinkedHashMap
<>();
links
.
put
(
"self"
,
new
Link
(
normalizedUrl
));
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -117,8 +117,7 @@ public abstract class AbstractWebFluxEndpointHandlerMapping
registerMapping
(
mapping
,
this
,
getLinks
());
}
protected
RequestMappingInfo
createRequestMappingInfo
(
WebOperation
operationInfo
)
{
protected
RequestMappingInfo
createRequestMappingInfo
(
WebOperation
operationInfo
)
{
OperationRequestPredicate
requestPredicate
=
operationInfo
.
getRequestPredicate
();
PatternsRequestCondition
patterns
=
new
PatternsRequestCondition
(
pathPatternParser
.
parse
(
this
.
endpointMapping
.
createSubPath
(
requestPredicate
.
getPath
())));
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -132,8 +132,7 @@ public abstract class AbstractWebMvcEndpointHandlerMapping
protected
abstract
void
registerMappingForOperation
(
WebOperation
operation
);
protected
RequestMappingInfo
createRequestMappingInfo
(
WebOperation
operationInfo
)
{
protected
RequestMappingInfo
createRequestMappingInfo
(
WebOperation
operationInfo
)
{
OperationRequestPredicate
requestPredicate
=
operationInfo
.
getRequestPredicate
();
PatternsRequestCondition
patterns
=
patternsRequestConditionForPattern
(
requestPredicate
.
getPath
());
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java
View file @
54c0cf51
...
...
@@ -91,8 +91,7 @@ public class MetricsEndpoint {
Map
<
Statistic
,
Double
>
samples
=
getSamples
(
meters
);
Map
<
String
,
Set
<
String
>>
availableTags
=
getAvailableTags
(
meters
);
tags
.
forEach
((
t
)
->
availableTags
.
remove
(
t
.
getKey
()));
return
new
MetricResponse
(
requiredMetricName
,
asList
(
samples
,
Sample:
:
new
),
return
new
MetricResponse
(
requiredMetricName
,
asList
(
samples
,
Sample:
:
new
),
asList
(
availableTags
,
AvailableTag:
:
new
));
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java
View file @
54c0cf51
...
...
@@ -247,14 +247,15 @@ public class WebMvcMetricsFilterTests {
@Bean
PrometheusMeterRegistry
prometheus
()
{
PrometheusMeterRegistry
r
=
new
PrometheusMeterRegistry
(
PrometheusConfig
.
DEFAULT
,
new
CollectorRegistry
(),
Clock
.
SYSTEM
);
PrometheusMeterRegistry
r
=
new
PrometheusMeterRegistry
(
PrometheusConfig
.
DEFAULT
,
new
CollectorRegistry
(),
Clock
.
SYSTEM
);
r
.
config
().
meterFilter
(
new
MeterFilter
()
{
@Override
public
MeterFilterReply
accept
(
Meter
.
Id
id
)
{
for
(
Tag
tag
:
id
.
getTags
())
{
if
(
tag
.
getKey
().
equals
(
"uri"
)
&&
(
tag
.
getValue
().
contains
(
"histogram"
)
||
tag
.
getValue
().
contains
(
"percentiles"
)))
{
||
tag
.
getValue
().
contains
(
"percentiles"
)))
{
return
MeterFilterReply
.
ACCEPT
;
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonProperties.java
View file @
54c0cf51
...
...
@@ -64,8 +64,8 @@ public class GsonProperties {
private
LongSerializationPolicy
longSerializationPolicy
;
/**
* Naming policy that should be applied to an object's field during serialization
*
and
deserialization.
* Naming policy that should be applied to an object's field during serialization
and
* deserialization.
*/
private
FieldNamingPolicy
fieldNamingPolicy
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/GsonHttpMessageConvertersConfiguration.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -75,7 +75,8 @@ class GsonHttpMessageConvertersConfiguration {
}
private
static
class
JacksonAndJsonbUnavailableCondition
extends
NoneNestedConditions
{
private
static
class
JacksonAndJsonbUnavailableCondition
extends
NoneNestedConditions
{
JacksonAndJsonbUnavailableCondition
()
{
super
(
ConfigurationPhase
.
REGISTER_BEAN
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionProperties.java
View file @
54c0cf51
...
...
@@ -53,7 +53,8 @@ public class SessionProperties {
public
SessionProperties
(
ObjectProvider
<
ServerProperties
>
serverProperties
)
{
ServerProperties
properties
=
serverProperties
.
getIfUnique
();
Session
session
=
(
properties
==
null
?
null
:
properties
.
getServlet
().
getSession
());
Session
session
=
(
properties
==
null
?
null
:
properties
.
getServlet
().
getSession
());
this
.
timeout
=
(
session
==
null
?
null
:
session
.
getTimeout
());
}
...
...
@@ -68,7 +69,7 @@ public class SessionProperties {
/**
* Return the session timeout.
* @return the session timeout
* @see Se
rverProperties.Servlet#getSession
()
* @see Se
ssion#getTimeout
()
*/
public
Duration
getTimeout
()
{
return
this
.
timeout
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/jetty/JettyCustomizer.java
View file @
54c0cf51
...
...
@@ -35,8 +35,7 @@ import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
import
org.springframework.core.env.Environment
;
/**
* Customization for Jetty-specific features common
* for both Servlet and Reactive servers.
* Customization for Jetty-specific features common for both Servlet and Reactive servers.
*
* @author Brian Clozel
* @since 2.0.0
...
...
@@ -58,16 +57,14 @@ public final class JettyCustomizer {
factory
.
setSelectors
(
jettyProperties
.
getSelectors
());
}
if
(
serverProperties
.
getMaxHttpHeaderSize
()
>
0
)
{
customizeMaxHttpHeaderSize
(
factory
,
serverProperties
.
getMaxHttpHeaderSize
());
customizeMaxHttpHeaderSize
(
factory
,
serverProperties
.
getMaxHttpHeaderSize
());
}
if
(
jettyProperties
.
getMaxHttpPostSize
()
>
0
)
{
customizeMaxHttpPostSize
(
factory
,
jettyProperties
.
getMaxHttpPostSize
());
}
if
(
serverProperties
.
getConnectionTimeout
()
!=
null
)
{
customizeConnectionTimeout
(
factory
,
serverProperties
.
getConnectionTimeout
());
customizeConnectionTimeout
(
factory
,
serverProperties
.
getConnectionTimeout
());
}
if
(
jettyProperties
.
getAccesslog
().
isEnabled
())
{
customizeAccessLog
(
factory
,
jettyProperties
.
getAccesslog
());
...
...
@@ -86,8 +83,7 @@ public final class JettyCustomizer {
private
static
void
customizeConnectionTimeout
(
ConfigurableJettyWebServerFactory
factory
,
Duration
connectionTimeout
)
{
factory
.
addServerCustomizers
((
server
)
->
{
for
(
org
.
eclipse
.
jetty
.
server
.
Connector
connector
:
server
.
getConnectors
())
{
for
(
org
.
eclipse
.
jetty
.
server
.
Connector
connector
:
server
.
getConnectors
())
{
if
(
connector
instanceof
AbstractConnector
)
{
((
AbstractConnector
)
connector
)
.
setIdleTimeout
(
connectionTimeout
.
toMillis
());
...
...
@@ -123,8 +119,8 @@ public final class JettyCustomizer {
});
}
private
static
void
customizeMaxHttpPostSize
(
ConfigurableJettyWebServerFactory
factory
,
int
maxHttpPostSize
)
{
private
static
void
customizeMaxHttpPostSize
(
ConfigurableJettyWebServerFactory
factory
,
int
maxHttpPostSize
)
{
factory
.
addServerCustomizers
(
new
JettyServerCustomizer
()
{
@Override
...
...
@@ -136,8 +132,7 @@ public final class JettyCustomizer {
Handler
...
handlers
)
{
for
(
Handler
handler
:
handlers
)
{
if
(
handler
instanceof
ContextHandler
)
{
((
ContextHandler
)
handler
)
.
setMaxFormContentSize
(
maxHttpPostSize
);
((
ContextHandler
)
handler
).
setMaxFormContentSize
(
maxHttpPostSize
);
}
else
if
(
handler
instanceof
HandlerWrapper
)
{
setHandlerMaxHttpPostSize
(
maxHttpPostSize
,
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/tomcat/TomcatCustomizer.java
View file @
54c0cf51
...
...
@@ -32,8 +32,8 @@ import org.springframework.core.env.Environment;
import
org.springframework.util.StringUtils
;
/**
* Customization for Tomcat-specific features common
*
for both Servlet and Reactive
servers.
* Customization for Tomcat-specific features common
for both Servlet and Reactive
* servers.
*
* @author Brian Clozel
* @since 2.0.0
...
...
@@ -50,8 +50,8 @@ public final class TomcatCustomizer {
factory
.
setBaseDirectory
(
tomcatProperties
.
getBasedir
());
}
if
(
tomcatProperties
.
getBackgroundProcessorDelay
()
!=
null
)
{
factory
.
setBackgroundProcessorDelay
(
(
int
)
tomcatProperties
.
getBackgroundProcessorDelay
().
getSeconds
());
factory
.
setBackgroundProcessorDelay
(
(
int
)
tomcatProperties
.
getBackgroundProcessorDelay
().
getSeconds
());
}
customizeRemoteIpValve
(
serverProperties
,
environment
,
factory
);
if
(
tomcatProperties
.
getMaxThreads
()
>
0
)
{
...
...
@@ -76,8 +76,7 @@ public final class TomcatCustomizer {
factory
.
setUriEncoding
(
tomcatProperties
.
getUriEncoding
());
}
if
(
serverProperties
.
getConnectionTimeout
()
!=
null
)
{
customizeConnectionTimeout
(
factory
,
serverProperties
.
getConnectionTimeout
());
customizeConnectionTimeout
(
factory
,
serverProperties
.
getConnectionTimeout
());
}
if
(
tomcatProperties
.
getMaxConnections
()
>
0
)
{
customizeMaxConnections
(
factory
,
tomcatProperties
.
getMaxConnections
());
...
...
@@ -99,8 +98,8 @@ public final class TomcatCustomizer {
});
}
private
static
void
customizeMaxConnections
(
ConfigurableTomcatWebServerFactory
factory
,
int
maxConnections
)
{
private
static
void
customizeMaxConnections
(
ConfigurableTomcatWebServerFactory
factory
,
int
maxConnections
)
{
factory
.
addConnectorCustomizers
((
connector
)
->
{
ProtocolHandler
handler
=
connector
.
getProtocolHandler
();
if
(
handler
instanceof
AbstractProtocol
)
{
...
...
@@ -129,8 +128,8 @@ public final class TomcatCustomizer {
if
(
StringUtils
.
hasText
(
protocolHeader
)
||
StringUtils
.
hasText
(
remoteIpHeader
)
||
getOrDeduceUseForwardHeaders
(
properties
,
environment
))
{
RemoteIpValve
valve
=
new
RemoteIpValve
();
valve
.
setProtocolHeader
(
StringUtils
.
hasLength
(
protocolHeader
)
?
protocolHeader
:
"X-Forwarded-Proto"
);
valve
.
setProtocolHeader
(
StringUtils
.
hasLength
(
protocolHeader
)
?
protocolHeader
:
"X-Forwarded-Proto"
);
if
(
StringUtils
.
hasLength
(
remoteIpHeader
))
{
valve
.
setRemoteIpHeader
(
remoteIpHeader
);
}
...
...
@@ -213,7 +212,8 @@ public final class TomcatCustomizer {
factory
.
addEngineValves
(
valve
);
}
private
static
void
customizeStaticResources
(
ServerProperties
.
Tomcat
.
Resource
resource
,
private
static
void
customizeStaticResources
(
ServerProperties
.
Tomcat
.
Resource
resource
,
ConfigurableTomcatWebServerFactory
factory
)
{
if
(
resource
.
getCacheTtl
()
==
null
)
{
return
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/undertow/UndertowCustomizer.java
View file @
54c0cf51
...
...
@@ -26,8 +26,8 @@ import org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebSer
import
org.springframework.core.env.Environment
;
/**
* Customization for Undertow-specific features common
*
for both Servlet and Reactive
servers.
* Customization for Undertow-specific features common
for both Servlet and Reactive
* servers.
*
* @author Brian Clozel
*/
...
...
@@ -62,18 +62,16 @@ public final class UndertowCustomizer {
factory
.
setAccessLogPrefix
(
accesslogProperties
.
getPrefix
());
factory
.
setAccessLogSuffix
(
accesslogProperties
.
getSuffix
());
factory
.
setAccessLogRotate
(
accesslogProperties
.
isRotate
());
factory
.
setUseForwardHeaders
(
getOrDeduceUseForwardHeaders
(
serverProperties
,
environment
));
factory
.
setUseForwardHeaders
(
getOrDeduceUseForwardHeaders
(
serverProperties
,
environment
));
if
(
serverProperties
.
getMaxHttpHeaderSize
()
>
0
)
{
customizeMaxHttpHeaderSize
(
factory
,
serverProperties
.
getMaxHttpHeaderSize
());
customizeMaxHttpHeaderSize
(
factory
,
serverProperties
.
getMaxHttpHeaderSize
());
}
if
(
undertowProperties
.
getMaxHttpPostSize
()
>
0
)
{
customizeMaxHttpPostSize
(
factory
,
undertowProperties
.
getMaxHttpPostSize
());
customizeMaxHttpPostSize
(
factory
,
undertowProperties
.
getMaxHttpPostSize
());
}
if
(
serverProperties
.
getConnectionTimeout
()
!=
null
)
{
customizeConnectionTimeout
(
factory
,
serverProperties
.
getConnectionTimeout
());
customizeConnectionTimeout
(
factory
,
serverProperties
.
getConnectionTimeout
());
}
factory
.
addDeploymentInfoCustomizers
((
deploymentInfo
)
->
deploymentInfo
.
setEagerFilterInit
(
undertowProperties
.
isEagerFilterInit
()));
...
...
@@ -82,8 +80,7 @@ public final class UndertowCustomizer {
private
static
void
customizeConnectionTimeout
(
ConfigurableUndertowWebServerFactory
factory
,
Duration
connectionTimeout
)
{
factory
.
addBuilderCustomizers
((
builder
)
->
builder
.
setSocketOption
(
UndertowOptions
.
NO_REQUEST_TIMEOUT
,
(
int
)
connectionTimeout
.
toMillis
()));
UndertowOptions
.
NO_REQUEST_TIMEOUT
,
(
int
)
connectionTimeout
.
toMillis
()));
}
private
static
void
customizeMaxHttpHeaderSize
(
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/DefaultReactiveWebServerFactoryCustomizer.java
View file @
54c0cf51
...
...
@@ -35,8 +35,9 @@ import org.springframework.core.env.Environment;
* @author Brian Clozel
* @since 2.0.0
*/
public
class
DefaultReactiveWebServerFactoryCustomizer
implements
WebServerFactoryCustomizer
<
ConfigurableReactiveWebServerFactory
>,
EnvironmentAware
,
Ordered
{
public
class
DefaultReactiveWebServerFactoryCustomizer
implements
WebServerFactoryCustomizer
<
ConfigurableReactiveWebServerFactory
>,
EnvironmentAware
,
Ordered
{
private
final
ServerProperties
serverProperties
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java
View file @
54c0cf51
...
...
@@ -192,7 +192,8 @@ public abstract class AbstractErrorWebExceptionHandler
.
append
(
"<p>This application has no configured error view, so you are seeing this as a fallback.</p>"
)
.
append
(
"<div id='created'>"
).
append
(
timestamp
.
toString
())
.
append
(
"</div>"
).
append
(
"<div>There was an unexpected error (type="
)
.
append
(
HtmlUtils
.
htmlEscape
(
error
.
get
(
"error"
).
toString
())).
append
(
", status="
)
.
append
(
HtmlUtils
.
htmlEscape
(
error
.
get
(
"error"
).
toString
()))
.
append
(
", status="
)
.
append
(
HtmlUtils
.
htmlEscape
(
error
.
get
(
"status"
).
toString
()))
.
append
(
").</div>"
).
append
(
"<div>"
)
.
append
(
HtmlUtils
.
htmlEscape
(
error
.
get
(
"message"
).
toString
()))
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorAttributes.java
View file @
54c0cf51
...
...
@@ -118,8 +118,8 @@ public class DefaultErrorAttributes implements ErrorAttributes {
errorAttributes
.
put
(
"trace"
,
stackTrace
.
toString
());
}
private
void
handleException
(
Map
<
String
,
Object
>
errorAttributes
,
Throwable
error
,
boolean
includeStackTrace
)
{
private
void
handleException
(
Map
<
String
,
Object
>
errorAttributes
,
Throwable
error
,
boolean
includeStackTrace
)
{
if
(
this
.
includeException
)
{
errorAttributes
.
put
(
"exception"
,
error
.
getClass
().
getName
());
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java
View file @
54c0cf51
...
...
@@ -217,22 +217,23 @@ public class WebMvcAutoConfiguration {
@Override
public
void
configurePathMatch
(
PathMatchConfigurer
configurer
)
{
configurer
.
setUseSuffixPatternMatch
(
this
.
mvcProperties
.
getPathMatch
().
isUseSuffixPattern
());
configurer
.
setUseRegisteredSuffixPatternMatch
(
this
.
mvcProperties
.
getPathMatch
().
isUseRegisteredSuffixPattern
());
configurer
.
setUseSuffixPatternMatch
(
this
.
mvcProperties
.
getPathMatch
().
isUseSuffixPattern
());
configurer
.
setUseRegisteredSuffixPatternMatch
(
this
.
mvcProperties
.
getPathMatch
().
isUseRegisteredSuffixPattern
());
}
@Override
public
void
configureContentNegotiation
(
ContentNegotiationConfigurer
configurer
)
{
WebMvcProperties
.
ContentNegotiation
contentNegotiation
=
this
.
mvcProperties
.
getContentNegotiation
();
WebMvcProperties
.
ContentNegotiation
contentNegotiation
=
this
.
mvcProperties
.
getContentNegotiation
();
configurer
.
favorPathExtension
(
contentNegotiation
.
isFavorPathExtension
());
configurer
.
favorParameter
(
contentNegotiation
.
isFavorParameter
());
if
(
contentNegotiation
.
getParameterName
()
!=
null
)
{
configurer
.
parameterName
(
contentNegotiation
.
getParameterName
());
}
Map
<
String
,
MediaType
>
mediaTypes
=
this
.
mvcProperties
.
getContentNegotiation
().
getMediaTypes
();
Map
<
String
,
MediaType
>
mediaTypes
=
this
.
mvcProperties
.
getContentNegotiation
()
.
getMediaTypes
();
for
(
Entry
<
String
,
MediaType
>
mediaType
:
mediaTypes
.
entrySet
())
{
configurer
.
mediaType
(
mediaType
.
getKey
(),
mediaType
.
getValue
());
}
...
...
@@ -324,8 +325,8 @@ public class WebMvcAutoConfiguration {
registry
.
addResourceHandler
(
"/webjars/**"
)
.
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
)
.
setCachePeriod
(
getSeconds
(
cachePeriod
))
.
setCacheControl
(
cacheControl
));
.
setCachePeriod
(
getSeconds
(
cachePeriod
))
.
setCacheControl
(
cacheControl
));
}
String
staticPathPattern
=
this
.
mvcProperties
.
getStaticPathPattern
();
if
(!
registry
.
hasMappingForPattern
(
staticPathPattern
))
{
...
...
@@ -333,8 +334,8 @@ public class WebMvcAutoConfiguration {
registry
.
addResourceHandler
(
staticPathPattern
)
.
addResourceLocations
(
getResourceLocations
(
this
.
resourceProperties
.
getStaticLocations
()))
.
setCachePeriod
(
getSeconds
(
cachePeriod
))
.
setCacheControl
(
cacheControl
));
.
setCachePeriod
(
getSeconds
(
cachePeriod
))
.
setCacheControl
(
cacheControl
));
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java
View file @
54c0cf51
...
...
@@ -273,20 +273,21 @@ public class WebMvcProperties {
public
static
class
ContentNegotiation
{
/**
* Whether the path extension in the URL path should be used to determine
*
the requested media type. If enabled a request "/users.pdf" will be
*
interpreted as
a request for "application/pdf" regardless of the 'Accept' header.
* Whether the path extension in the URL path should be used to determine
the
*
requested media type. If enabled a request "/users.pdf" will be interpreted as
* a request for "application/pdf" regardless of the 'Accept' header.
*/
private
boolean
favorPathExtension
=
false
;
/**
* Whether a request parameter ("format" by default) should be used to
*
determine
the requested media type.
* Whether a request parameter ("format" by default) should be used to
determine
* the requested media type.
*/
private
boolean
favorParameter
=
false
;
/**
* Maps file extensions to media types for content negotiation, e.g. yml to text/yaml.
* Maps file extensions to media types for content negotiation, e.g. yml to
* text/yaml.
*/
private
Map
<
String
,
MediaType
>
mediaTypes
=
new
LinkedHashMap
<>();
...
...
@@ -331,16 +332,16 @@ public class WebMvcProperties {
public
static
class
PathMatch
{
/**
* Whether to use suffix pattern match (".*") when matching patterns to
*
requests.
If enabled a method mapped to "/users" also matches to "/users.*".
* Whether to use suffix pattern match (".*") when matching patterns to
requests.
* If enabled a method mapped to "/users" also matches to "/users.*".
*/
private
boolean
useSuffixPattern
=
false
;
/**
* Whether suffix pattern matching should work only against extensions
*
registered with "spring.mvc.content-negotiation.media-types.*".
*
This is generally recommended to reduce ambiguity and to
*
avoid issues such as when a "." appears
in the path for other reasons.
* Whether suffix pattern matching should work only against extensions
registered
*
with "spring.mvc.content-negotiation.media-types.*". This is generally
*
recommended to reduce ambiguity and to avoid issues such as when a "." appears
* in the path for other reasons.
*/
private
boolean
useRegisteredSuffixPattern
=
false
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfiguration.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -35,9 +35,7 @@ import org.springframework.messaging.converter.MessageConverter;
import
org.springframework.messaging.converter.StringMessageConverter
;
import
org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration
;
import
org.springframework.util.MimeTypeUtils
;
import
org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer
;
import
org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration
;
import
org.springframework.web.socket.config.annotation.StompEndpointRegistry
;
import
org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
;
/**
...
...
@@ -56,7 +54,7 @@ public class WebSocketMessagingAutoConfiguration {
ObjectMapper
.
class
})
@ConditionalOnClass
({
ObjectMapper
.
class
,
AbstractMessageBrokerConfiguration
.
class
})
static
class
WebSocketMessageConverterConfiguration
extends
Abstract
WebSocketMessageBrokerConfigurer
{
implements
WebSocketMessageBrokerConfigurer
{
private
final
ObjectMapper
objectMapper
;
...
...
@@ -64,11 +62,6 @@ public class WebSocketMessagingAutoConfiguration {
this
.
objectMapper
=
objectMapper
;
}
@Override
public
void
registerStompEndpoints
(
StompEndpointRegistry
registry
)
{
// The user must register their own endpoints
}
@Override
public
boolean
configureMessageConverters
(
List
<
MessageConverter
>
messageConverters
)
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java
View file @
54c0cf51
...
...
@@ -321,8 +321,7 @@ public class CacheAutoConfigurationTests {
@Test
public
void
redisCacheWithCustomizers
()
{
this
.
contextRunner
.
withUserConfiguration
(
RedisWithCustomizersConfiguration
.
class
)
this
.
contextRunner
.
withUserConfiguration
(
RedisWithCustomizersConfiguration
.
class
)
.
withPropertyValues
(
"spring.cache.type="
+
"redis"
)
.
run
(
dunno
(
"allCacheManagerCustomizer"
,
"redisCacheManagerCustomizer"
));
}
...
...
@@ -954,8 +953,7 @@ public class CacheAutoConfigurationTests {
@Bean
public
org
.
springframework
.
data
.
redis
.
cache
.
RedisCacheConfiguration
customRedisCacheConfiguration
()
{
return
org
.
springframework
.
data
.
redis
.
cache
.
RedisCacheConfiguration
.
defaultCacheConfig
()
.
entryTtl
(
java
.
time
.
Duration
.
ofSeconds
(
30
))
.
defaultCacheConfig
().
entryTtl
(
java
.
time
.
Duration
.
ofSeconds
(
30
))
.
prefixKeysWith
(
"bar"
);
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfigurationTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -67,8 +67,8 @@ public class MongoRepositoriesAutoConfigurationTests {
@Test
public
void
testNoRepositoryConfiguration
()
{
this
.
runner
.
withUserConfiguration
(
EmptyConfiguration
.
class
)
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
MongoClient
.
class
));
this
.
runner
.
withUserConfiguration
(
EmptyConfiguration
.
class
)
.
run
((
context
)
->
assertThat
(
context
).
hasSingleBean
(
MongoClient
.
class
));
}
@Test
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerInvokerTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -60,8 +60,7 @@ public class DataSourceInitializerInvokerTests {
private
ApplicationContextRunner
contextRunner
=
new
ApplicationContextRunner
()
.
withConfiguration
(
AutoConfigurations
.
of
(
DataSourceAutoConfiguration
.
class
))
.
withPropertyValues
(
"spring.datasource.initialization-mode=never"
,
"spring.datasource.url:jdbc:hsqldb:mem:init-"
+
UUID
.
randomUUID
());
"spring.datasource.url:jdbc:hsqldb:mem:init-"
+
UUID
.
randomUUID
());
@Test
public
void
dataSourceInitialized
()
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -194,8 +194,7 @@ public class MailSenderAutoConfigurationTests {
verify
(
mailSender
,
never
()).
testConnection
();
}
private
Session
configureJndiSession
(
String
name
)
throws
IllegalStateException
{
private
Session
configureJndiSession
(
String
name
)
throws
IllegalStateException
{
Properties
properties
=
new
Properties
();
Session
session
=
Session
.
getDefaultInstance
(
properties
);
TestableInitialContextFactory
.
bind
(
name
,
session
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityFilterAutoConfigurationEarlyInitializationTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -63,7 +63,8 @@ public class SecurityFilterAutoConfigurationEarlyInitializationTests {
context
.
refresh
();
int
port
=
context
.
getWebServer
().
getPort
();
String
password
=
this
.
outputCapture
.
toString
()
.
split
(
"Using generated security password: "
)[
1
].
split
(
"\n"
)[
0
].
trim
();
.
split
(
"Using generated security password: "
)[
1
].
split
(
"\n"
)[
0
]
.
trim
();
new
TestRestTemplate
(
"user"
,
password
)
.
getForEntity
(
"http://localhost:"
+
port
,
Object
.
class
);
// If early initialization occurred a ConverterNotFoundException is thrown
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationTests.java
View file @
54c0cf51
...
...
@@ -153,24 +153,24 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat
@Test
public
void
sessionCookieConfigurationIsPickedUp
()
{
new
WebApplicationContextRunner
(
WebApplicationContextRunner
webRunner
=
new
WebApplicationContextRunner
(
AnnotationConfigServletWebServerApplicationContext:
:
new
)
.
withConfiguration
(
AutoConfigurations
.
of
(
ServletWebServerFactoryAutoConfiguration
.
class
))
.
withUserConfiguration
(
SessionRepositoryConfiguration
.
class
)
.
withPropertyValues
(
"server.port=0"
,
"server.servlet.session.cookie.name=testname"
)
.
run
((
context
)
->
{
SessionRepositoryFilter
<?>
filter
=
context
.
getBean
(
SessionRepositoryFilter
.
class
);
CookieHttpSessionIdResolver
sessionIdResolver
=
(
CookieHttpSessionIdResolver
)
ReflectionTestUtils
.
getField
(
filter
,
"httpSessionIdResolver"
);
DefaultCookieSerializer
cookieSerializer
=
(
DefaultCookieSerializer
)
ReflectionTestUtils
.
getField
(
sessionIdResolver
,
"cookieSerializer"
);
String
cookieName
=
(
String
)
ReflectionTestUtils
.
getField
(
cookieSerializer
,
"cookieName"
);
assertThat
(
cookieName
).
isEqualTo
(
"testname"
);
});
"server.servlet.session.cookie.name=testname"
)
;
webRunner
.
run
((
context
)
->
{
SessionRepositoryFilter
<?>
filter
=
context
.
getBean
(
SessionRepositoryFilter
.
class
);
CookieHttpSessionIdResolver
sessionIdResolver
=
(
CookieHttpSessionIdResolver
)
ReflectionTestUtils
.
getField
(
filter
,
"httpSessionIdResolver"
);
DefaultCookieSerializer
cookieSerializer
=
(
DefaultCookieSerializer
)
ReflectionTestUtils
.
getField
(
sessionIdResolver
,
"cookieSerializer"
);
String
cookieName
=
(
String
)
ReflectionTestUtils
.
getField
(
cookieSerializer
,
"cookieName"
);
assertThat
(
cookieName
).
isEqualTo
(
"testname"
);
});
}
@Configuration
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/DefaultReactiveWebServerFactoryCustomizerTests.java
View file @
54c0cf51
...
...
@@ -170,7 +170,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
public
void
defaultTomcatBackgroundProcessorDelay
()
{
TomcatReactiveWebServerFactory
factory
=
new
TomcatReactiveWebServerFactory
();
this
.
customizer
.
customize
(
factory
);
TomcatWebServer
webServer
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
TomcatWebServer
webServer
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
assertThat
(
webServer
.
getTomcat
().
getEngine
().
getBackgroundProcessorDelay
())
.
isEqualTo
(
30
);
webServer
.
stop
();
...
...
@@ -183,7 +184,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
bindProperties
(
map
);
TomcatReactiveWebServerFactory
factory
=
new
TomcatReactiveWebServerFactory
();
this
.
customizer
.
customize
(
factory
);
TomcatWebServer
webServer
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
TomcatWebServer
webServer
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
assertThat
(
webServer
.
getTomcat
().
getEngine
().
getBackgroundProcessorDelay
())
.
isEqualTo
(
5
);
webServer
.
stop
();
...
...
@@ -261,7 +263,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
bindProperties
(
map
);
TomcatReactiveWebServerFactory
factory
=
new
TomcatReactiveWebServerFactory
(
0
);
this
.
customizer
.
customize
(
factory
);
TomcatWebServer
server
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
TomcatWebServer
server
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
server
.
start
();
try
{
assertThat
(((
AbstractProtocol
<?>)
server
.
getTomcat
().
getConnector
()
...
...
@@ -279,7 +282,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
bindProperties
(
map
);
TomcatReactiveWebServerFactory
factory
=
new
TomcatReactiveWebServerFactory
(
0
);
this
.
customizer
.
customize
(
factory
);
TomcatWebServer
server
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
TomcatWebServer
server
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
server
.
start
();
try
{
assertThat
(((
AbstractProtocol
<?>)
server
.
getTomcat
().
getConnector
()
...
...
@@ -297,7 +301,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
bindProperties
(
map
);
TomcatReactiveWebServerFactory
factory
=
new
TomcatReactiveWebServerFactory
(
0
);
this
.
customizer
.
customize
(
factory
);
TomcatWebServer
server
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
TomcatWebServer
server
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
server
.
start
();
try
{
assertThat
(
server
.
getTomcat
().
getConnector
().
getMaxPostSize
())
...
...
@@ -315,7 +320,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
bindProperties
(
map
);
TomcatReactiveWebServerFactory
factory
=
new
TomcatReactiveWebServerFactory
(
0
);
this
.
customizer
.
customize
(
factory
);
TomcatWebServer
server
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
TomcatWebServer
server
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
server
.
start
();
try
{
assertThat
(
server
.
getTomcat
().
getConnector
().
getMaxPostSize
()).
isEqualTo
(-
1
);
...
...
@@ -340,7 +346,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
bindProperties
(
map
);
TomcatReactiveWebServerFactory
factory
=
new
TomcatReactiveWebServerFactory
(
0
);
this
.
customizer
.
customize
(
factory
);
TomcatWebServer
server
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
TomcatWebServer
server
=
(
TomcatWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
server
.
start
();
try
{
Tomcat
tomcat
=
server
.
getTomcat
();
...
...
@@ -382,7 +389,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
map
.
put
(
"server.jetty.accesslog.enabled"
,
"true"
);
bindProperties
(
map
);
this
.
customizer
.
customize
(
factory
);
JettyWebServer
webServer
=
(
JettyWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
JettyWebServer
webServer
=
(
JettyWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
try
{
NCSARequestLog
requestLog
=
getNCSARequestLog
(
webServer
);
assertThat
(
requestLog
.
getFilename
()).
isNull
();
...
...
@@ -417,7 +425,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
map
.
put
(
"server.jetty.accesslog.log-latency"
,
"true"
);
bindProperties
(
map
);
this
.
customizer
.
customize
(
factory
);
JettyWebServer
webServer
=
(
JettyWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
JettyWebServer
webServer
=
(
JettyWebServer
)
factory
.
getWebServer
(
mock
(
HttpHandler
.
class
));
NCSARequestLog
requestLog
=
getNCSARequestLog
(
webServer
);
try
{
assertThat
(
requestLog
.
getFilename
()).
isEqualTo
(
logFile
.
getAbsolutePath
());
...
...
@@ -461,7 +470,8 @@ public class DefaultReactiveWebServerFactoryCustomizerTests {
@Test
public
void
setUseForwardHeadersUndertow
()
{
this
.
properties
.
setUseForwardHeaders
(
true
);
UndertowReactiveWebServerFactory
factory
=
spy
(
new
UndertowReactiveWebServerFactory
());
UndertowReactiveWebServerFactory
factory
=
spy
(
new
UndertowReactiveWebServerFactory
());
this
.
customizer
.
customize
(
factory
);
verify
(
factory
).
setUseForwardHeaders
(
true
);
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerAutoConfigurationTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -54,8 +54,9 @@ public class ReactiveWebServerAutoConfigurationTests {
.
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
WebServerFactoryCustomizer
.
class
))
.
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
DefaultReactiveWebServerFactoryCustomizer
.
class
))
.
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
DefaultReactiveWebServerFactoryCustomizer
.
class
))
.
hasSize
(
1
);
}
@Test
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java
View file @
54c0cf51
...
...
@@ -233,8 +233,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.
contentType
(
MediaType
.
TEXT_HTML
).
expectBody
(
String
.
class
)
.
returnResult
().
getResponseBody
();
assertThat
(
body
).
contains
(
"Whitelabel Error Page"
)
.
doesNotContain
(
"<script>"
)
.
contains
(
"<script>"
);
.
doesNotContain
(
"<script>"
).
contains
(
"<script>"
);
this
.
output
.
expect
(
allOf
(
containsString
(
"Failed to handle request [GET /html]"
),
containsString
(
"IllegalStateException"
)));
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java
View file @
54c0cf51
...
...
@@ -471,9 +471,10 @@ public class WebMvcAutoConfigurationTests {
@Test
public
void
customMediaTypes
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.mvc.content-negotiation.media-types.yaml:text/yaml"
,
"spring.mvc.content-negotiation.favor-path-extension:true"
)
this
.
contextRunner
.
withPropertyValues
(
"spring.mvc.content-negotiation.media-types.yaml:text/yaml"
,
"spring.mvc.content-negotiation.favor-path-extension:true"
)
.
run
((
context
)
->
{
RequestMappingHandlerAdapter
adapter
=
context
.
getBean
(
RequestMappingHandlerAdapter
.
class
);
...
...
@@ -744,7 +745,8 @@ public class WebMvcAutoConfigurationTests {
@Test
public
void
defaultPathMatching
()
{
this
.
contextRunner
.
run
((
context
)
->
{
RequestMappingHandlerMapping
handlerMapping
=
context
.
getBean
(
RequestMappingHandlerMapping
.
class
);
RequestMappingHandlerMapping
handlerMapping
=
context
.
getBean
(
RequestMappingHandlerMapping
.
class
);
assertThat
(
handlerMapping
.
useSuffixPatternMatch
()).
isFalse
();
assertThat
(
handlerMapping
.
useRegisteredSuffixPatternMatch
()).
isFalse
();
});
...
...
@@ -756,34 +758,40 @@ public class WebMvcAutoConfigurationTests {
.
withPropertyValues
(
"spring.mvc.path-match.use-suffix-pattern:true"
,
"spring.mvc.path-match.use-registered-suffix-pattern:true"
)
.
run
((
context
)
->
{
RequestMappingHandlerMapping
handlerMapping
=
context
.
getBean
(
RequestMappingHandlerMapping
.
class
);
assertThat
(
handlerMapping
.
useSuffixPatternMatch
()).
isTrue
();
assertThat
(
handlerMapping
.
useRegisteredSuffixPatternMatch
()).
isTrue
();
});
RequestMappingHandlerMapping
handlerMapping
=
context
.
getBean
(
RequestMappingHandlerMapping
.
class
);
assertThat
(
handlerMapping
.
useSuffixPatternMatch
()).
isTrue
();
assertThat
(
handlerMapping
.
useRegisteredSuffixPatternMatch
()).
isTrue
();
});
}
@Test
public
void
defaultContentNegotiation
()
{
this
.
contextRunner
.
run
((
context
)
->
{
RequestMappingHandlerMapping
handlerMapping
=
context
.
getBean
(
RequestMappingHandlerMapping
.
class
);
ContentNegotiationManager
contentNegotiationManager
=
handlerMapping
.
getContentNegotiationManager
();
RequestMappingHandlerMapping
handlerMapping
=
context
.
getBean
(
RequestMappingHandlerMapping
.
class
);
ContentNegotiationManager
contentNegotiationManager
=
handlerMapping
.
getContentNegotiationManager
();
assertThat
(
contentNegotiationManager
.
getStrategies
())
.
doesNotHaveAnyElementsOfTypes
(
WebMvcAutoConfiguration
.
OptionalPathExtensionContentNegotiationStrategy
.
class
);
.
doesNotHaveAnyElementsOfTypes
(
WebMvcAutoConfiguration
.
OptionalPathExtensionContentNegotiationStrategy
.
class
);
});
}
@Test
public
void
pathExtensionContentNegotiation
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.mvc.content-negotiation.favor-path-extension:true"
)
.
withPropertyValues
(
"spring.mvc.content-negotiation.favor-path-extension:true"
)
.
run
((
context
)
->
{
RequestMappingHandlerMapping
handlerMapping
=
context
.
getBean
(
RequestMappingHandlerMapping
.
class
);
ContentNegotiationManager
contentNegotiationManager
=
handlerMapping
.
getContentNegotiationManager
();
assertThat
(
contentNegotiationManager
.
getStrategies
())
.
hasAtLeastOneElementOfType
(
WebMvcAutoConfiguration
.
OptionalPathExtensionContentNegotiationStrategy
.
class
);
});
RequestMappingHandlerMapping
handlerMapping
=
context
.
getBean
(
RequestMappingHandlerMapping
.
class
);
ContentNegotiationManager
contentNegotiationManager
=
handlerMapping
.
getContentNegotiationManager
();
assertThat
(
contentNegotiationManager
.
getStrategies
())
.
hasAtLeastOneElementOfType
(
WebMvcAutoConfiguration
.
OptionalPathExtensionContentNegotiationStrategy
.
class
);
});
}
@Test
...
...
@@ -791,10 +799,13 @@ public class WebMvcAutoConfigurationTests {
this
.
contextRunner
.
withPropertyValues
(
"spring.mvc.content-negotiation.favor-parameter:true"
)
.
run
((
context
)
->
{
RequestMappingHandlerMapping
handlerMapping
=
context
.
getBean
(
RequestMappingHandlerMapping
.
class
);
ContentNegotiationManager
contentNegotiationManager
=
handlerMapping
.
getContentNegotiationManager
();
RequestMappingHandlerMapping
handlerMapping
=
context
.
getBean
(
RequestMappingHandlerMapping
.
class
);
ContentNegotiationManager
contentNegotiationManager
=
handlerMapping
.
getContentNegotiationManager
();
assertThat
(
contentNegotiationManager
.
getStrategies
())
.
hasAtLeastOneElementOfType
(
ParameterContentNegotiationStrategy
.
class
);
.
hasAtLeastOneElementOfType
(
ParameterContentNegotiationStrategy
.
class
);
});
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageHandlerMappingTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -75,7 +75,8 @@ public class WelcomePageHandlerMappingTests {
public
void
handlesRequestForStaticPageThatAcceptsAll
()
{
this
.
contextRunner
.
withUserConfiguration
(
StaticResourceConfiguration
.
class
)
.
run
((
context
)
->
MockMvcBuilders
.
webAppContextSetup
(
context
).
build
()
.
perform
(
get
(
"/"
).
accept
(
MediaType
.
ALL
)).
andExpect
(
status
().
isOk
())
.
perform
(
get
(
"/"
).
accept
(
MediaType
.
ALL
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
forwardedUrl
(
"index.html"
)));
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -57,11 +57,11 @@ import org.springframework.stereotype.Controller;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.socket.client.standard.StandardWebSocketClient
;
import
org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer
;
import
org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration
;
import
org.springframework.web.socket.config.annotation.EnableWebSocket
;
import
org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker
;
import
org.springframework.web.socket.config.annotation.StompEndpointRegistry
;
import
org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
;
import
org.springframework.web.socket.messaging.WebSocketStompClient
;
import
org.springframework.web.socket.sockjs.client.RestTemplateXhrTransport
;
import
org.springframework.web.socket.sockjs.client.SockJsClient
;
...
...
@@ -213,7 +213,7 @@ public class WebSocketMessagingAutoConfigurationTests {
WebSocketMessagingAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
})
static
class
WebSocketMessagingConfiguration
extends
Abstract
WebSocketMessageBrokerConfigurer
{
implements
WebSocketMessageBrokerConfigurer
{
@Override
public
void
registerStompEndpoints
(
StompEndpointRegistry
registry
)
{
...
...
spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GenericBomAstTransformation.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -43,8 +43,8 @@ import org.springframework.core.Ordered;
* dependencies in the BOM (and its transitives) will be added to the dependency
* management lookup, so an app can use just the artifact id (e.g. "spring-jdbc") in a
* {@code @Grab}. To install, implement the missing methods and list the class in
* {@code META-INF/services/org.springframework.boot.cli.compiler.SpringBootAstTransformation}
.
* The {@link #getOrder()} value needs to be before
* {@code META-INF/services/org.springframework.boot.cli.compiler.SpringBootAstTransformation}
*
.
The {@link #getOrder()} value needs to be before
* {@link DependencyManagementBomTransformation#ORDER}.
*
* @author Dave Syer
...
...
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/autoconfigure/UserServiceAutoConfiguration.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -40,7 +40,6 @@ public class UserServiceAutoConfiguration {
return
new
UserService
(
properties
.
getName
());
}
@ConfigurationProperties
(
"user"
)
static
class
UserProperties
{
...
...
spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/test/web/RandomPortWebTestClientExampleTests.java
View file @
54c0cf51
...
...
@@ -36,10 +36,7 @@ public class RandomPortWebTestClientExampleTests {
@Test
public
void
exampleTest
()
{
this
.
webClient
.
get
()
.
uri
(
"/"
)
.
exchange
()
.
expectStatus
().
isOk
()
this
.
webClient
.
get
().
uri
(
"/"
).
exchange
().
expectStatus
().
isOk
()
.
expectBody
(
String
.
class
).
isEqualTo
(
"Hello World"
);
}
...
...
spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/jdbc/SimpleTwoDataSourcesExampleTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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,7 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll
*/
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
properties
=
{
"app.datasource.second.url=jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1"
,
@SpringBootTest
(
properties
=
{
"app.datasource.second.url=jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1"
,
"app.datasource.second.max-total=42"
})
@Import
(
SimpleTwoDataSourcesExample
.
SimpleDataSourcesConfiguration
.
class
)
public
class
SimpleTwoDataSourcesExampleTests
{
...
...
@@ -55,7 +56,8 @@ public class SimpleTwoDataSourcesExampleTests {
.
startsWith
(
"jdbc:h2:mem:"
);
BasicDataSource
secondDataSource
=
this
.
context
.
getBean
(
"secondDataSource"
,
BasicDataSource
.
class
);
assertThat
(
secondDataSource
.
getUrl
()).
isEqualTo
(
"jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1"
);
assertThat
(
secondDataSource
.
getUrl
())
.
isEqualTo
(
"jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1"
);
assertThat
(
secondDataSource
.
getMaxTotal
()).
isEqualTo
(
42
);
}
...
...
spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/AbstractJsonMarshalTester.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -371,8 +371,7 @@ public abstract class AbstractJsonMarshalTester<T> {
initFields
(
testInstance
,
()
->
marshaller
);
}
public
void
initFields
(
Object
testInstance
,
final
ObjectFactory
<
M
>
marshaller
)
{
public
void
initFields
(
Object
testInstance
,
final
ObjectFactory
<
M
>
marshaller
)
{
Assert
.
notNull
(
testInstance
,
"TestInstance must not be null"
);
Assert
.
notNull
(
marshaller
,
"Marshaller must not be null"
);
ReflectionUtils
.
doWithFields
(
testInstance
.
getClass
(),
...
...
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -131,8 +131,7 @@ public class TestRestTemplateTests {
ReflectionUtils
.
doWithMethods
(
RestOperations
.
class
,
new
MethodCallback
()
{
@Override
public
void
doWith
(
Method
method
)
throws
IllegalArgumentException
{
public
void
doWith
(
Method
method
)
throws
IllegalArgumentException
{
Method
equivalent
=
ReflectionUtils
.
findMethod
(
TestRestTemplate
.
class
,
method
.
getName
(),
method
.
getParameterTypes
());
assertThat
(
equivalent
).
as
(
"Method %s not found"
,
method
).
isNotNull
();
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilder.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -155,8 +155,8 @@ public final class ConfigurationMetadataRepositoryJsonBuilder {
}
/**
* Create a new builder instance using {@link StandardCharsets#UTF_8} as the default
charset and the
* specified json resource.
* Create a new builder instance using {@link StandardCharsets#UTF_8} as the default
*
charset and the
specified json resource.
* @param inputStreams the source input streams
* @return a new {@link ConfigurationMetadataRepositoryJsonBuilder} instance.
* @throws IOException on error
...
...
@@ -171,7 +171,8 @@ public final class ConfigurationMetadataRepositoryJsonBuilder {
}
/**
* Create a new builder instance using {@link StandardCharsets#UTF_8} as the default charset.
* Create a new builder instance using {@link StandardCharsets#UTF_8} as the default
* charset.
* @return a new {@link ConfigurationMetadataRepositoryJsonBuilder} instance.
*/
public
static
ConfigurationMetadataRepositoryJsonBuilder
create
()
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONArray.java
View file @
54c0cf51
...
...
@@ -52,7 +52,7 @@ public class JSONArray {
* Creates a {@code JSONArray} with no values.
*/
public
JSONArray
()
{
this
.
values
=
new
ArrayList
<
Object
>();
this
.
values
=
new
ArrayList
<>();
}
/**
...
...
@@ -111,7 +111,7 @@ public class JSONArray {
throw
new
JSONException
(
"Not a primitive array: "
+
array
.
getClass
());
}
final
int
length
=
Array
.
getLength
(
array
);
this
.
values
=
new
ArrayList
<
Object
>(
length
);
this
.
values
=
new
ArrayList
<>(
length
);
for
(
int
i
=
0
;
i
<
length
;
++
i
)
{
put
(
JSONObject
.
wrap
(
Array
.
get
(
array
,
i
)));
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONObject.java
View file @
54c0cf51
...
...
@@ -111,7 +111,7 @@ public class JSONObject {
* Creates a {@code JSONObject} with no name/value mappings.
*/
public
JSONObject
()
{
this
.
nameValuePairs
=
new
HashMap
<
String
,
Object
>();
this
.
nameValuePairs
=
new
HashMap
<>();
}
/**
...
...
@@ -691,7 +691,7 @@ public class JSONObject {
*/
public
JSONArray
names
()
{
return
this
.
nameValuePairs
.
isEmpty
()
?
null
:
new
JSONArray
(
new
ArrayList
<
String
>(
this
.
nameValuePairs
.
keySet
()));
:
new
JSONArray
(
new
ArrayList
<>(
this
.
nameValuePairs
.
keySet
()));
}
/**
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONStringer.java
View file @
54c0cf51
...
...
@@ -109,7 +109,7 @@ public class JSONStringer {
* Unlike the original implementation, this stack isn't limited to 20 levels of
* nesting.
*/
private
final
List
<
Scope
>
stack
=
new
ArrayList
<
Scope
>();
private
final
List
<
Scope
>
stack
=
new
ArrayList
<>();
/**
* A string containing a full set of spaces for a single level of indentation, or null
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -166,7 +166,6 @@ class TypeUtils {
return
WRAPPER_TO_PRIMITIVE
.
get
(
type
.
toString
());
}
/**
* A visitor that extracts the full qualified name of a type, including generic
* information.
...
...
@@ -202,7 +201,7 @@ class TypeUtils {
if
(
enclosingElement
!=
null
)
{
return
getQualifiedName
(
enclosingElement
)
+
"$"
+
((
DeclaredType
)
element
.
asType
()).
asElement
().
getSimpleName
()
.
toString
();
.
toString
();
}
if
(
element
instanceof
TypeElement
)
{
return
((
TypeElement
)
element
).
getQualifiedName
().
toString
();
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/JsonMarshaller.java
View file @
54c0cf51
...
...
@@ -167,7 +167,8 @@ public class JsonMarshaller {
private
String
toString
(
InputStream
inputStream
)
throws
IOException
{
StringBuilder
out
=
new
StringBuilder
();
InputStreamReader
reader
=
new
InputStreamReader
(
inputStream
,
StandardCharsets
.
UTF_8
);
InputStreamReader
reader
=
new
InputStreamReader
(
inputStream
,
StandardCharsets
.
UTF_8
);
char
[]
buffer
=
new
char
[
BUFFER_SIZE
];
int
bytesRead
;
while
((
bytesRead
=
reader
.
read
(
buffer
))
!=
-
1
)
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/TestProject.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -191,8 +191,7 @@ public class TestProject {
return
new
File
(
TestCompiler
.
SOURCE_FOLDER
,
TestCompiler
.
sourcePathFor
(
type
));
}
private
static
void
putContents
(
File
targetFile
,
String
contents
)
throws
IOException
{
private
static
void
putContents
(
File
targetFile
,
String
contents
)
throws
IOException
{
FileCopyUtils
.
copy
(
new
StringReader
(
contents
),
new
FileWriter
(
targetFile
));
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java
View file @
54c0cf51
...
...
@@ -47,6 +47,7 @@ import org.springframework.util.StringUtils;
final
class
JavaPluginAction
implements
PluginApplicationAction
{
private
static
final
String
PARAMETERS_COMPILER_ARG
=
"-parameters"
;
private
final
SinglePublishedArtifact
singlePublishedArtifact
;
JavaPluginAction
(
SinglePublishedArtifact
singlePublishedArtifact
)
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/TestJarFile.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -86,8 +86,7 @@ public class TestJarFile {
return
file
;
}
private
void
copyToFile
(
InputStream
inputStream
,
File
file
)
throws
IOException
{
private
void
copyToFile
(
InputStream
inputStream
,
File
file
)
throws
IOException
{
try
(
OutputStream
outputStream
=
new
FileOutputStream
(
file
))
{
copy
(
inputStream
,
outputStream
);
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -24,8 +24,8 @@ import java.util.Set;
* Helper class for resolving placeholders in texts. Usually applied to file paths.
* <p>
* A text may contain {@code $ ...} placeholders, to be resolved as system properties:
* e.g. {@code $ user.dir}. Default values can be supplied using the ":" separator
*
between
key and value.
* e.g. {@code $ user.dir}. Default values can be supplied using the ":" separator
between
* key and value.
* <p>
* Adapted from Spring.
*
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/data/RandomAccessDataFileTests.java
View file @
54c0cf51
...
...
@@ -104,8 +104,8 @@ public class RandomAccessDataFileTests {
public
void
fileExists
()
{
File
file
=
new
File
(
"/does/not/exist"
);
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
String
.
format
(
"File %s must exist"
,
file
.
getAbsolutePath
()));
this
.
thrown
.
expectMessage
(
String
.
format
(
"File %s must exist"
,
file
.
getAbsolutePath
()));
new
RandomAccessDataFile
(
file
);
}
...
...
@@ -120,8 +120,8 @@ public class RandomAccessDataFileTests {
public
void
fileExistsWithConcurrentReads
()
{
File
file
=
new
File
(
"/does/not/exist"
);
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
String
.
format
(
"File %s must exist"
,
file
.
getAbsolutePath
()));
this
.
thrown
.
expectMessage
(
String
.
format
(
"File %s must exist"
,
file
.
getAbsolutePath
()));
new
RandomAccessDataFile
(
file
,
1
);
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/PropertyMapper.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -112,7 +112,7 @@ public final class PropertyMapper {
if
(
this
.
parent
!=
null
)
{
return
this
.
parent
.
from
(
supplier
);
}
return
new
Source
<
T
>(
new
CachingSupplier
<>(
supplier
),
(
Predicate
<
T
>)
ALWAYS
);
return
new
Source
<>(
new
CachingSupplier
<>(
supplier
),
(
Predicate
<
T
>)
ALWAYS
);
}
/**
...
...
@@ -207,7 +207,7 @@ public final class PropertyMapper {
}
return
null
;
};
return
new
Source
<
R
>(
supplier
,
predicate
);
return
new
Source
<>(
supplier
,
predicate
);
}
/**
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -351,8 +351,8 @@ public class Binder {
* @return a {@link Binder} instance
*/
public
static
Binder
get
(
Environment
environment
)
{
return
new
Binder
(
ConfigurationPropertySources
.
get
(
environment
),
new
PropertySourcesPlaceholdersResolver
(
environment
));
return
new
Binder
(
ConfigurationPropertySources
.
get
(
environment
),
new
PropertySourcesPlaceholdersResolver
(
environment
));
}
/**
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/convert/DurationConverter.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -51,7 +51,8 @@ class DurationConverter implements GenericConverter {
private
static
final
Pattern
ISO8601
=
Pattern
.
compile
(
"^[\\+\\-]?P.*$"
);
private
static
final
Pattern
SIMPLE
=
Pattern
.
compile
(
"^([\\+\\-]?\\d+)([a-zA-Z]{0,2})$"
);
private
static
final
Pattern
SIMPLE
=
Pattern
.
compile
(
"^([\\+\\-]?\\d+)([a-zA-Z]{0,2})$"
);
private
static
final
Map
<
String
,
ChronoUnit
>
UNITS
;
...
...
@@ -90,7 +91,8 @@ class DurationConverter implements GenericConverter {
return
Duration
.
parse
(
source
);
}
Matcher
matcher
=
SIMPLE
.
matcher
(
source
);
Assert
.
state
(
matcher
.
matches
(),
()
->
"'"
+
source
+
"' is not a valid duration"
);
Assert
.
state
(
matcher
.
matches
(),
()
->
"'"
+
source
+
"' is not a valid duration"
);
long
amount
=
Long
.
parseLong
(
matcher
.
group
(
1
));
ChronoUnit
unit
=
getUnit
(
matcher
.
group
(
2
),
defaultUnit
);
return
Duration
.
of
(
amount
,
unit
);
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java
View file @
54c0cf51
...
...
@@ -26,8 +26,8 @@ import org.springframework.util.Assert;
import
org.springframework.web.server.ServerWebExchange
;
/**
* {@link ApplicationContext} backed {@link ServerWebExchangeMatcher}. Can work directly
with the
* {@link ApplicationContext}, obtain an existing bean or
* {@link ApplicationContext} backed {@link ServerWebExchangeMatcher}. Can work directly
*
with the
{@link ApplicationContext}, obtain an existing bean or
* {@link AutowireCapableBeanFactory#createBean(Class, int, boolean) create a new bean}
* that is autowired in the usual way.
*
...
...
@@ -38,7 +38,8 @@ import org.springframework.web.server.ServerWebExchange;
* @author Madhura Bhave
* @since 2.0.0
*/
public
abstract
class
ApplicationContextServerWebExchangeMatcher
<
C
>
implements
ServerWebExchangeMatcher
{
public
abstract
class
ApplicationContextServerWebExchangeMatcher
<
C
>
implements
ServerWebExchangeMatcher
{
private
final
Class
<?
extends
C
>
contextClass
;
...
...
@@ -101,4 +102,3 @@ public abstract class ApplicationContextServerWebExchangeMatcher<C> implements S
}
}
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyReactiveWebServerFactory.java
View file @
54c0cf51
...
...
@@ -178,8 +178,8 @@ public class JettyReactiveWebServerFactory extends AbstractReactiveWebServerFact
JettyHandlerWrappers
.
createGzipHandlerWrapper
(
getCompression
()));
}
if
(
StringUtils
.
hasText
(
getServerHeader
()))
{
handler
=
applyWrapper
(
handler
,
JettyHandlerWrappers
.
createServerHeaderHandlerWrapper
(
getServerHeader
()));
handler
=
applyWrapper
(
handler
,
JettyHandlerWrappers
.
createServerHeaderHandlerWrapper
(
getServerHeader
()));
}
return
handler
;
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java
View file @
54c0cf51
...
...
@@ -182,8 +182,8 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor
JettyHandlerWrappers
.
createGzipHandlerWrapper
(
getCompression
()));
}
if
(
StringUtils
.
hasText
(
getServerHeader
()))
{
handler
=
applyWrapper
(
handler
,
JettyHandlerWrappers
.
createServerHeaderHandlerWrapper
(
getServerHeader
()));
handler
=
applyWrapper
(
handler
,
JettyHandlerWrappers
.
createServerHeaderHandlerWrapper
(
getServerHeader
()));
}
return
handler
;
}
...
...
@@ -530,7 +530,6 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor
}
}
private
static
final
class
LoaderHidingResource
extends
Resource
{
private
final
Resource
delegate
;
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactory.java
View file @
54c0cf51
...
...
@@ -80,7 +80,6 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac
private
int
backgroundProcessorDelay
;
/**
* Create a new {@link TomcatServletWebServerFactory} instance.
*/
...
...
@@ -304,8 +303,8 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac
}
/**
* Set {@link LifecycleListener}s that should be applied to the Tomcat
{@link Context}.
* Calling this method will replace any existing listeners.
* Set {@link LifecycleListener}s that should be applied to the Tomcat
*
{@link Context}.
Calling this method will replace any existing listeners.
* @param contextLifecycleListeners the listeners to set
*/
public
void
setContextLifecycleListeners
(
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java
View file @
54c0cf51
...
...
@@ -42,8 +42,8 @@ import org.springframework.util.Assert;
/**
* {@link WebServer} that can be used to control a Tomcat web server. Usually this class
* should be created using the {@link TomcatReactiveWebServerFactory}
*
of
{@link TomcatServletWebServerFactory}, but not directly.
* should be created using the {@link TomcatReactiveWebServerFactory}
of
* {@link TomcatServletWebServerFactory}, but not directly.
*
* @author Brian Clozel
* @author Kristine Jetzke
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowCompressionConfigurer.java
View file @
54c0cf51
...
...
@@ -52,7 +52,8 @@ final class UndertowCompressionConfigurer {
* @param httpHandler the HTTP handler to wrap
* @return the wrapped HTTP handler if compression is enabled, or the handler itself
*/
public
static
HttpHandler
configureCompression
(
Compression
compression
,
HttpHandler
httpHandler
)
{
public
static
HttpHandler
configureCompression
(
Compression
compression
,
HttpHandler
httpHandler
)
{
if
(
compression
==
null
||
!
compression
.
getEnabled
())
{
return
httpHandler
;
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java
View file @
54c0cf51
...
...
@@ -77,7 +77,6 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF
private
boolean
useForwardHeaders
;
/**
* Create a new {@link UndertowReactiveWebServerFactory} instance.
*/
...
...
@@ -94,7 +93,8 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF
}
@Override
public
WebServer
getWebServer
(
org
.
springframework
.
http
.
server
.
reactive
.
HttpHandler
httpHandler
)
{
public
WebServer
getWebServer
(
org
.
springframework
.
http
.
server
.
reactive
.
HttpHandler
httpHandler
)
{
Undertow
.
Builder
builder
=
createBuilder
(
getPort
());
HttpHandler
handler
=
createUndertowHandler
(
httpHandler
);
builder
.
setHandler
(
handler
);
...
...
@@ -127,19 +127,22 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF
return
builder
;
}
private
HttpHandler
createUndertowHandler
(
org
.
springframework
.
http
.
server
.
reactive
.
HttpHandler
httpHandler
)
{
private
HttpHandler
createUndertowHandler
(
org
.
springframework
.
http
.
server
.
reactive
.
HttpHandler
httpHandler
)
{
HttpHandler
handler
=
new
UndertowHttpHandlerAdapter
(
httpHandler
);
if
(
this
.
useForwardHeaders
)
{
handler
=
Handlers
.
proxyPeerAddress
(
handler
);
}
handler
=
UndertowCompressionConfigurer
.
configureCompression
(
getCompression
(),
handler
);
handler
=
UndertowCompressionConfigurer
.
configureCompression
(
getCompression
(),
handler
);
if
(
isAccessLogEnabled
())
{
handler
=
createAccessLogHandler
(
handler
);
}
return
handler
;
}
private
AccessLogHandler
createAccessLogHandler
(
io
.
undertow
.
server
.
HttpHandler
handler
)
{
private
AccessLogHandler
createAccessLogHandler
(
io
.
undertow
.
server
.
HttpHandler
handler
)
{
try
{
createAccessLogDirectoryIfNecessary
();
String
prefix
=
(
this
.
accessLogPrefix
!=
null
?
this
.
accessLogPrefix
...
...
@@ -175,8 +178,7 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF
new
SslBuilderCustomizer
(
getPort
(),
getAddress
(),
getSsl
(),
getSslStoreProvider
())
.
customize
(
builder
);
if
(
getHttp2
()
!=
null
)
{
builder
.
setServerOption
(
UndertowOptions
.
ENABLE_HTTP2
,
getHttp2
().
isEnabled
());
builder
.
setServerOption
(
UndertowOptions
.
ENABLE_HTTP2
,
getHttp2
().
isEnabled
());
}
}
...
...
@@ -304,6 +306,7 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF
* Undertow {@link io.undertow.Undertow.Builder Builder}.
* @param customizers the customizers to add
*/
@Override
public
void
addBuilderCustomizers
(
UndertowBuilderCustomizer
...
customizers
)
{
Assert
.
notNull
(
customizers
,
"Customizers must not be null"
);
this
.
builderCustomizers
.
addAll
(
Arrays
.
asList
(
customizers
));
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java
View file @
54c0cf51
...
...
@@ -452,6 +452,7 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac
this
.
ioThreads
=
ioThreads
;
}
@Override
public
void
setWorkerThreads
(
Integer
workerThreads
)
{
this
.
workerThreads
=
workerThreads
;
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java
View file @
54c0cf51
...
...
@@ -35,8 +35,9 @@ import org.springframework.util.ReflectionUtils;
import
org.springframework.util.StringUtils
;
/**
* {@link WebServer} that can be used to control an Undertow web server. Usually this class
* should be created using the {@link UndertowReactiveWebServerFactory} and not directly.
* {@link WebServer} that can be used to control an Undertow web server. Usually this
* class should be created using the {@link UndertowReactiveWebServerFactory} and not
* directly.
*
* @author Ivan Sopov
* @author Andy Wilkinson
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/AnnotationConfigReactiveWebServerApplicationContext.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -125,8 +125,8 @@ public class AnnotationConfigReactiveWebServerApplicationContext
/**
* Provide a custom {@link BeanNameGenerator} for use with
* {@link AnnotatedBeanDefinitionReader} and/or
{@link ClassPathBeanDefinitionScanner},
* if any.
* {@link AnnotatedBeanDefinitionReader} and/or
*
{@link ClassPathBeanDefinitionScanner},
if any.
* <p>
* Default is
* {@link org.springframework.context.annotation.AnnotationBeanNameGenerator}.
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/DynamicRegistrationBean.java
View file @
54c0cf51
...
...
@@ -58,8 +58,8 @@ public abstract class DynamicRegistrationBean<D extends Registration.Dynamic>
}
/**
* Sets if asynchronous operations are supported for this registration. If not
specified
* defaults to {@code true}.
* Sets if asynchronous operations are supported for this registration. If not
*
specified
defaults to {@code true}.
* @param asyncSupported if async is supported
*/
public
void
setAsyncSupported
(
boolean
asyncSupported
)
{
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java
View file @
54c0cf51
...
...
@@ -246,8 +246,8 @@ public class ServletContextInitializerBeans
}
/**
* Adapter to convert a given Bean type into a {@link RegistrationBean} (and
*
hence a
{@link ServletContextInitializer}).
* Adapter to convert a given Bean type into a {@link RegistrationBean} (and
hence a
* {@link ServletContextInitializer}).
*/
private
interface
RegistrationBeanAdapter
<
T
>
{
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContext.java
View file @
54c0cf51
...
...
@@ -123,8 +123,8 @@ public class AnnotationConfigServletWebServerApplicationContext
/**
* Provide a custom {@link BeanNameGenerator} for use with
* {@link AnnotatedBeanDefinitionReader} and/or
{@link ClassPathBeanDefinitionScanner},
* if any.
* {@link AnnotatedBeanDefinitionReader} and/or
*
{@link ClassPathBeanDefinitionScanner},
if any.
* <p>
* Default is
* {@link org.springframework.context.annotation.AnnotationBeanNameGenerator}.
...
...
@@ -169,6 +169,7 @@ public class AnnotationConfigServletWebServerApplicationContext
* @see #scan(String...)
* @see #refresh()
*/
@Override
public
final
void
register
(
Class
<?>...
annotatedClasses
)
{
Assert
.
notEmpty
(
annotatedClasses
,
"At least one annotated class must be specified"
);
...
...
@@ -182,6 +183,7 @@ public class AnnotationConfigServletWebServerApplicationContext
* @see #register(Class...)
* @see #refresh()
*/
@Override
public
final
void
scan
(
String
...
basePackages
)
{
Assert
.
notEmpty
(
basePackages
,
"At least one base package must be specified"
);
this
.
basePackages
=
basePackages
;
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/SessionStoreDirectory.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -56,7 +56,8 @@ class SessionStoreDirectory {
}
private
void
assertDirectory
(
boolean
mkdirs
,
File
dir
)
{
Assert
.
state
(!
mkdirs
||
dir
.
exists
(),
()
->
"Session dir "
+
dir
+
" does not exist"
);
Assert
.
state
(!
mkdirs
||
dir
.
exists
(),
()
->
"Session dir "
+
dir
+
" does not exist"
);
Assert
.
state
(!
dir
.
isFile
(),
()
->
"Session dir "
+
dir
+
" points to a file"
);
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ExitCodeGeneratorsTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -100,8 +100,7 @@ public class ExitCodeGeneratorsTests {
return
generator
;
}
private
ExitCodeExceptionMapper
mockMapper
(
Class
<?>
exceptionType
,
int
exitCode
)
{
private
ExitCodeExceptionMapper
mockMapper
(
Class
<?>
exceptionType
,
int
exitCode
)
{
return
(
exception
)
->
{
if
(
exceptionType
.
isInstance
(
exception
))
{
return
exitCode
;
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/convert/DurationConverterTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -137,7 +137,8 @@ public class DurationConverterTests {
private
Duration
convert
(
String
source
,
ChronoUnit
defaultUnit
)
{
TypeDescriptor
targetType
=
mock
(
TypeDescriptor
.
class
);
DefaultDurationUnit
annotation
=
AnnotationUtils
.
synthesizeAnnotation
(
Collections
.
singletonMap
(
"value"
,
defaultUnit
),
DefaultDurationUnit
.
class
,
null
);
Collections
.
singletonMap
(
"value"
,
defaultUnit
),
DefaultDurationUnit
.
class
,
null
);
given
(
targetType
.
getAnnotation
(
DefaultDurationUnit
.
class
)).
willReturn
(
annotation
);
return
(
Duration
)
this
.
converter
.
convert
(
source
,
TypeDescriptor
.
forObject
(
source
),
targetType
);
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/liquibase/LiquibaseServiceLocatorApplicationListenerTests.java
View file @
54c0cf51
...
...
@@ -69,8 +69,8 @@ public class LiquibaseServiceLocatorApplicationListenerTests {
SpringApplication
application
=
new
SpringApplication
(
Conf
.
class
);
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
DefaultResourceLoader
resourceLoader
=
new
DefaultResourceLoader
();
resourceLoader
.
setClassLoader
(
new
ClassHidingClassLoader
(
CustomResolverServiceLocator
.
class
));
resourceLoader
.
setClassLoader
(
new
ClassHidingClassLoader
(
CustomResolverServiceLocator
.
class
));
application
.
setResourceLoader
(
resourceLoader
);
this
.
context
=
application
.
run
();
Object
resolver
=
getServiceLocator
();
...
...
@@ -94,7 +94,8 @@ public class LiquibaseServiceLocatorApplicationListenerTests {
private
final
List
<
Class
<?>>
hiddenClasses
;
private
ClassHidingClassLoader
(
Class
<?>...
hiddenClasses
)
{
super
(
new
URL
[
0
],
LiquibaseServiceLocatorApplicationListenerTests
.
class
.
getClassLoader
());
super
(
new
URL
[
0
],
LiquibaseServiceLocatorApplicationListenerTests
.
class
.
getClassLoader
());
this
.
hiddenClasses
=
Arrays
.
asList
(
hiddenClasses
);
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcherTests.java
View file @
54c0cf51
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -55,34 +55,40 @@ public class ApplicationContextServerWebExchangeMatcherTests {
@Test
public
void
matchesWhenContextClassIsApplicationContextShouldProvideContext
()
{
ServerWebExchange
exchange
=
createHttpWebHandlerAdapter
();
StaticApplicationContext
context
=
(
StaticApplicationContext
)
exchange
.
getApplicationContext
();
assertThat
(
new
TestApplicationContextServerWebExchangeMatcher
<>(
ApplicationContext
.
class
)
.
callMatchesAndReturnProvidedContext
(
exchange
)).
isEqualTo
(
context
);
StaticApplicationContext
context
=
(
StaticApplicationContext
)
exchange
.
getApplicationContext
();
assertThat
(
new
TestApplicationContextServerWebExchangeMatcher
<>(
ApplicationContext
.
class
).
callMatchesAndReturnProvidedContext
(
exchange
))
.
isEqualTo
(
context
);
}
@Test
public
void
matchesWhenContextClassIsExistingBeanShouldProvideBean
()
{
ServerWebExchange
exchange
=
createHttpWebHandlerAdapter
();
StaticApplicationContext
context
=
(
StaticApplicationContext
)
exchange
.
getApplicationContext
();
StaticApplicationContext
context
=
(
StaticApplicationContext
)
exchange
.
getApplicationContext
();
context
.
registerSingleton
(
"existingBean"
,
ExistingBean
.
class
);
assertThat
(
new
TestApplicationContextServerWebExchangeMatcher
<>(
ExistingBean
.
class
)
.
callMatchesAndReturnProvidedContext
(
exchange
))
.
isEqualTo
(
context
.
getBean
(
ExistingBean
.
class
));
assertThat
(
new
TestApplicationContextServerWebExchangeMatcher
<>(
ExistingBean
.
class
)
.
callMatchesAndReturnProvidedContext
(
exchange
))
.
isEqualTo
(
context
.
getBean
(
ExistingBean
.
class
));
}
@Test
public
void
matchesWhenContextClassIsNewBeanShouldProvideBean
()
{
ServerWebExchange
exchange
=
createHttpWebHandlerAdapter
();
StaticApplicationContext
context
=
(
StaticApplicationContext
)
exchange
.
getApplicationContext
();
StaticApplicationContext
context
=
(
StaticApplicationContext
)
exchange
.
getApplicationContext
();
context
.
registerSingleton
(
"existingBean"
,
ExistingBean
.
class
);
assertThat
(
new
TestApplicationContextServerWebExchangeMatcher
<>(
NewBean
.
class
)
.
callMatchesAndReturnProvidedContext
(
exchange
).
getBean
())
.
isEqualTo
(
context
.
getBean
(
ExistingBean
.
class
));
.
isEqualTo
(
context
.
getBean
(
ExistingBean
.
class
));
}
@Test
public
void
matchesWhenContextIsNull
()
{
MockServerWebExchange
exchange
=
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"/path"
).
build
());
MockServerWebExchange
exchange
=
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"/path"
).
build
());
this
.
thrown
.
expect
(
IllegalStateException
.
class
);
this
.
thrown
.
expectMessage
(
"No WebApplicationContext found."
);
new
TestApplicationContextServerWebExchangeMatcher
<>(
ExistingBean
.
class
)
...
...
@@ -91,9 +97,11 @@ public class ApplicationContextServerWebExchangeMatcherTests {
private
ServerWebExchange
createHttpWebHandlerAdapter
()
{
StaticApplicationContext
context
=
new
StaticApplicationContext
();
TestHttpWebHandlerAdapter
adapter
=
new
TestHttpWebHandlerAdapter
(
mock
(
WebHandler
.
class
));
TestHttpWebHandlerAdapter
adapter
=
new
TestHttpWebHandlerAdapter
(
mock
(
WebHandler
.
class
));
adapter
.
setApplicationContext
(
context
);
return
adapter
.
createExchange
(
MockServerHttpRequest
.
get
(
"/path"
).
build
(),
new
MockServerHttpResponse
());
return
adapter
.
createExchange
(
MockServerHttpRequest
.
get
(
"/path"
).
build
(),
new
MockServerHttpResponse
());
}
static
class
TestHttpWebHandlerAdapter
extends
HttpWebHandlerAdapter
{
...
...
@@ -103,7 +111,8 @@ public class ApplicationContextServerWebExchangeMatcherTests {
}
@Override
protected
ServerWebExchange
createExchange
(
ServerHttpRequest
request
,
ServerHttpResponse
response
)
{
protected
ServerWebExchange
createExchange
(
ServerHttpRequest
request
,
ServerHttpResponse
response
)
{
return
super
.
createExchange
(
request
,
response
);
}
...
...
@@ -154,4 +163,3 @@ public class ApplicationContextServerWebExchangeMatcherTests {
}
}
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java
View file @
54c0cf51
...
...
@@ -149,7 +149,8 @@ public abstract class AbstractReactiveWebServerFactoryTests {
}
@Test
public
void
sslWantsClientAuthenticationSucceedsWithClientCertificate
()
throws
Exception
{
public
void
sslWantsClientAuthenticationSucceedsWithClientCertificate
()
throws
Exception
{
Ssl
ssl
=
new
Ssl
();
ssl
.
setClientAuth
(
Ssl
.
ClientAuth
.
WANT
);
ssl
.
setKeyStore
(
"classpath:test.jks"
);
...
...
@@ -159,9 +160,9 @@ public abstract class AbstractReactiveWebServerFactoryTests {
testClientAuthSuccess
(
ssl
,
buildTrustAllSslWithClientKeyConnector
());
}
@Test
public
void
sslWantsClientAuthenticationSucceedsWithoutClientCertificate
()
throws
Exception
{
public
void
sslWantsClientAuthenticationSucceedsWithoutClientCertificate
()
throws
Exception
{
Ssl
ssl
=
new
Ssl
();
ssl
.
setClientAuth
(
Ssl
.
ClientAuth
.
WANT
);
ssl
.
setKeyStore
(
"classpath:test.jks"
);
...
...
@@ -171,12 +172,13 @@ public abstract class AbstractReactiveWebServerFactoryTests {
testClientAuthSuccess
(
ssl
,
buildTrustAllSslConnector
());
}
protected
ReactorClientHttpConnector
buildTrustAllSslWithClientKeyConnector
()
throws
Exception
{
protected
ReactorClientHttpConnector
buildTrustAllSslWithClientKeyConnector
()
throws
Exception
{
KeyStore
clientKeyStore
=
KeyStore
.
getInstance
(
KeyStore
.
getDefaultType
());
clientKeyStore
.
load
(
new
FileInputStream
(
new
File
(
"src/test/resources/test.jks"
)),
"secret"
.
toCharArray
());
KeyManagerFactory
clientKeyManagerFactory
=
KeyManagerFactory
.
getInstance
(
KeyManagerFactory
.
getDefaultAlgorithm
());
KeyManagerFactory
clientKeyManagerFactory
=
KeyManagerFactory
.
getInstance
(
KeyManagerFactory
.
getDefaultAlgorithm
());
clientKeyManagerFactory
.
init
(
clientKeyStore
,
"password"
.
toCharArray
());
return
new
ReactorClientHttpConnector
(
(
options
)
->
options
.
sslSupport
(
sslContextBuilder
->
{
...
...
@@ -186,7 +188,8 @@ public abstract class AbstractReactiveWebServerFactoryTests {
}));
}
protected
void
testClientAuthSuccess
(
Ssl
sslConfiguration
,
ReactorClientHttpConnector
clientConnector
)
{
protected
void
testClientAuthSuccess
(
Ssl
sslConfiguration
,
ReactorClientHttpConnector
clientConnector
)
{
AbstractReactiveWebServerFactory
factory
=
getFactory
();
factory
.
setSsl
(
sslConfiguration
);
...
...
@@ -203,7 +206,8 @@ public abstract class AbstractReactiveWebServerFactoryTests {
}
@Test
public
void
sslNeedsClientAuthenticationSucceedsWithClientCertificate
()
throws
Exception
{
public
void
sslNeedsClientAuthenticationSucceedsWithClientCertificate
()
throws
Exception
{
Ssl
ssl
=
new
Ssl
();
ssl
.
setClientAuth
(
Ssl
.
ClientAuth
.
NEED
);
ssl
.
setKeyStore
(
"classpath:test.jks"
);
...
...
@@ -214,9 +218,11 @@ public abstract class AbstractReactiveWebServerFactoryTests {
}
@Test
public
void
sslNeedsClientAuthenticationFailsWithoutClientCertificate
()
throws
Exception
{
public
void
sslNeedsClientAuthenticationFailsWithoutClientCertificate
()
throws
Exception
{
// Ignored for Undertow, see https://github.com/reactor/reactor-netty/issues/257
Assumptions
.
assumeThat
(
getFactory
()).
isNotInstanceOf
(
UndertowReactiveWebServerFactory
.
class
);
Assumptions
.
assumeThat
(
getFactory
())
.
isNotInstanceOf
(
UndertowReactiveWebServerFactory
.
class
);
Ssl
ssl
=
new
Ssl
();
ssl
.
setClientAuth
(
Ssl
.
ClientAuth
.
NEED
);
ssl
.
setKeyStore
(
"classpath:test.jks"
);
...
...
@@ -226,7 +232,8 @@ public abstract class AbstractReactiveWebServerFactoryTests {
testClientAuthFailure
(
ssl
,
buildTrustAllSslConnector
());
}
protected
void
testClientAuthFailure
(
Ssl
sslConfiguration
,
ReactorClientHttpConnector
clientConnector
)
{
protected
void
testClientAuthFailure
(
Ssl
sslConfiguration
,
ReactorClientHttpConnector
clientConnector
)
{
AbstractReactiveWebServerFactory
factory
=
getFactory
();
factory
.
setSsl
(
sslConfiguration
);
...
...
@@ -240,17 +247,17 @@ public abstract class AbstractReactiveWebServerFactoryTests {
.
body
(
BodyInserters
.
fromObject
(
"Hello World"
)).
exchange
()
.
flatMap
((
response
)
->
response
.
bodyToMono
(
String
.
class
));
StepVerifier
.
create
(
result
)
.
expectError
(
SSLException
.
class
)
StepVerifier
.
create
(
result
).
expectError
(
SSLException
.
class
)
.
verify
(
Duration
.
ofSeconds
(
10
));
}
protected
WebClient
.
Builder
getWebClient
()
{
return
getWebClient
(
options
->
{
return
getWebClient
(
(
options
)
->
{
});
}
protected
WebClient
.
Builder
getWebClient
(
Consumer
<?
super
HttpClientOptions
.
Builder
>
clientOptions
)
{
protected
WebClient
.
Builder
getWebClient
(
Consumer
<?
super
HttpClientOptions
.
Builder
>
clientOptions
)
{
return
WebClient
.
builder
()
.
clientConnector
(
new
ReactorClientHttpConnector
(
clientOptions
))
.
baseUrl
(
"http://localhost:"
+
this
.
webServer
.
getPort
());
...
...
@@ -259,51 +266,54 @@ public abstract class AbstractReactiveWebServerFactoryTests {
@Test
public
void
compressionOfResponseToGetRequest
()
throws
Exception
{
WebClient
client
=
prepareCompressionTest
();
ResponseEntity
<
Void
>
response
=
client
.
get
()
.
exchange
().
flatMap
(
res
->
res
.
toEntity
(
Void
.
class
)).
block
();
ResponseEntity
<
Void
>
response
=
client
.
get
()
.
exchange
()
.
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
();
assertResponseIsCompressed
(
response
);
}
@Test
public
void
compressionOfResponseToPostRequest
()
throws
Exception
{
WebClient
client
=
prepareCompressionTest
();
ResponseEntity
<
Void
>
response
=
client
.
post
()
.
exchange
().
flatMap
(
res
->
res
.
toEntity
(
Void
.
class
)).
block
();
ResponseEntity
<
Void
>
response
=
client
.
post
()
.
exchange
()
.
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
();
assertResponseIsCompressed
(
response
);
}
@Test
public
void
noCompressionForSmallResponse
()
throws
Exception
{
Assumptions
.
assumeThat
(
getFactory
()).
isInstanceOf
(
NettyReactiveWebServerFactory
.
class
);
Assumptions
.
assumeThat
(
getFactory
())
.
isInstanceOf
(
NettyReactiveWebServerFactory
.
class
);
Compression
compression
=
new
Compression
();
compression
.
setEnabled
(
true
);
compression
.
setMinResponseSize
(
3001
);
WebClient
client
=
prepareCompressionTest
(
compression
);
ResponseEntity
<
Void
>
response
=
client
.
get
()
.
exchange
().
flatMap
(
res
->
res
.
toEntity
(
Void
.
class
)).
block
();
ResponseEntity
<
Void
>
response
=
client
.
get
()
.
exchange
()
.
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
();
assertResponseIsNotCompressed
(
response
);
}
@Test
public
void
noCompressionForMimeType
()
throws
Exception
{
Assumptions
.
assumeThat
(
getFactory
()).
isNotInstanceOf
(
NettyReactiveWebServerFactory
.
class
);
Assumptions
.
assumeThat
(
getFactory
())
.
isNotInstanceOf
(
NettyReactiveWebServerFactory
.
class
);
Compression
compression
=
new
Compression
();
compression
.
setMimeTypes
(
new
String
[]
{
"application/json"
});
compression
.
setMimeTypes
(
new
String
[]
{
"application/json"
});
WebClient
client
=
prepareCompressionTest
(
compression
);
ResponseEntity
<
Void
>
response
=
client
.
get
()
.
exchange
().
flatMap
(
res
->
res
.
toEntity
(
Void
.
class
)).
block
();
ResponseEntity
<
Void
>
response
=
client
.
get
()
.
exchange
()
.
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
();
assertResponseIsNotCompressed
(
response
);
}
@Test
public
void
noCompressionForUserAgent
()
throws
Exception
{
Assumptions
.
assumeThat
(
getFactory
()).
isNotInstanceOf
(
NettyReactiveWebServerFactory
.
class
);
Assumptions
.
assumeThat
(
getFactory
())
.
isNotInstanceOf
(
NettyReactiveWebServerFactory
.
class
);
Compression
compression
=
new
Compression
();
compression
.
setEnabled
(
true
);
compression
.
setExcludedUserAgents
(
new
String
[]
{
"testUserAgent"
});
WebClient
client
=
prepareCompressionTest
(
compression
);
ResponseEntity
<
Void
>
response
=
client
.
get
().
header
(
"User-Agent"
,
"testUserAgent"
)
.
exchange
().
flatMap
(
res
->
res
.
toEntity
(
Void
.
class
)).
block
();
.
exchange
().
flatMap
(
(
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
();
assertResponseIsNotCompressed
(
response
);
}
...
...
@@ -313,15 +323,17 @@ public abstract class AbstractReactiveWebServerFactoryTests {
return
prepareCompressionTest
(
compression
);
}
protected
WebClient
prepareCompressionTest
(
Compression
compression
)
{
AbstractReactiveWebServerFactory
factory
=
getFactory
();
factory
.
setCompression
(
compression
);
this
.
webServer
=
factory
.
getWebServer
(
new
CharsHandler
(
3000
,
MediaType
.
TEXT_PLAIN
));
this
.
webServer
=
factory
.
getWebServer
(
new
CharsHandler
(
3000
,
MediaType
.
TEXT_PLAIN
));
this
.
webServer
.
start
();
return
getWebClient
(
options
->
options
.
compression
(
true
).
afterChannelInit
(
channel
->
{
channel
.
pipeline
().
addBefore
(
NettyPipeline
.
HttpDecompressor
,
"CompressionTest"
,
new
CompressionDetectionHandler
());
}
)).
build
();
return
getWebClient
(
(
options
)
->
options
.
compression
(
true
)
.
afterChannelInit
((
channel
)
->
channel
.
pipeline
().
addBefore
(
NettyPipeline
.
HttpDecompressor
,
"CompressionTest"
,
new
CompressionDetectionHandler
())
)).
build
();
}
protected
void
assertResponseIsCompressed
(
ResponseEntity
<
Void
>
response
)
{
...
...
@@ -345,7 +357,8 @@ public abstract class AbstractReactiveWebServerFactoryTests {
}
protected
static
class
CompressionDetectionHandler
extends
ChannelInboundHandlerAdapter
{
protected
static
class
CompressionDetectionHandler
extends
ChannelInboundHandlerAdapter
{
@Override
public
void
channelRead
(
ChannelHandlerContext
ctx
,
Object
msg
)
throws
Exception
{
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java
View file @
54c0cf51
...
...
@@ -1018,7 +1018,7 @@ public abstract class AbstractServletWebServerFactoryTests {
factory
.
getSession
().
getCookie
().
setHttpOnly
(
true
);
factory
.
getSession
().
getCookie
().
setSecure
(
true
);
factory
.
getSession
().
getCookie
().
setMaxAge
(
Duration
.
ofMinutes
(
1
));
AtomicReference
<
ServletContext
>
contextReference
=
new
AtomicReference
<
ServletContext
>();
AtomicReference
<
ServletContext
>
contextReference
=
new
AtomicReference
<>();
factory
.
getWebServer
(
contextReference:
:
set
).
start
();
ServletContext
servletContext
=
contextReference
.
get
();
assertThat
(
servletContext
.
getEffectiveSessionTrackingModes
())
...
...
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