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
3e4da3cc
Commit
3e4da3cc
authored
Feb 27, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
c7ed5c3d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
139 additions
and
134 deletions
+139
-134
ElasticsearchHealthIndicatorAutoConfiguration.java
...search/ElasticsearchHealthIndicatorAutoConfiguration.java
+1
-1
RedisReactiveHealthIndicatorConfiguration.java
...gure/redis/RedisReactiveHealthIndicatorConfiguration.java
+1
-1
RedisAutoConfiguration.java
...boot/autoconfigure/data/redis/RedisAutoConfiguration.java
+1
-1
AppSystemPropertiesTests.java
...ocs/context/properties/bind/AppSystemPropertiesTests.java
+26
-16
SampleWebClientConfiguration.java
...rk/boot/docs/web/client/SampleWebClientConfiguration.java
+2
-3
SampleWebClientTests.java
...gframework/boot/docs/web/client/SampleWebClientTests.java
+1
-3
ApplicationPluginActionIntegrationTests.java
...radle/plugin/ApplicationPluginActionIntegrationTests.java
+1
-1
BindConverter.java
...framework/boot/context/properties/bind/BindConverter.java
+92
-84
JettyServletWebServerFactoryTests.java
...web/embedded/jetty/JettyServletWebServerFactoryTests.java
+14
-24
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticsearchHealthIndicatorAutoConfiguration.java
View file @
3e4da3cc
/*
* 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.
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/redis/RedisReactiveHealthIndicatorConfiguration.java
View file @
3e4da3cc
/*
* 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.
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java
View file @
3e4da3cc
/*
* 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.
...
...
spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/properties/bind/AppSystemPropertiesTests.java
View file @
3e4da3cc
...
...
@@ -41,36 +41,46 @@ public class AppSystemPropertiesTests {
@Test
public
void
bindWithDefaultUnit
()
{
this
.
contextRunner
.
withPropertyValues
(
"app.system.session-timeout=40"
,
"app.system.read-timeout=5000"
).
run
(
assertBinding
(
p
->
{
assertThat
(
p
.
getSessionTimeout
()).
isEqualTo
(
Duration
.
ofSeconds
(
40
));
assertThat
(
p
.
getReadTimeout
()).
isEqualTo
(
Duration
.
ofMillis
(
5000
));
}));
this
.
contextRunner
.
withPropertyValues
(
"app.system.session-timeout=40"
,
"app.system.read-timeout=5000"
)
.
run
(
assertBinding
((
properties
)
->
{
assertThat
(
properties
.
getSessionTimeout
())
.
isEqualTo
(
Duration
.
ofSeconds
(
40
));
assertThat
(
properties
.
getReadTimeout
())
.
isEqualTo
(
Duration
.
ofMillis
(
5000
));
}));
}
@Test
public
void
bindWithExplicitUnit
()
{
this
.
contextRunner
.
withPropertyValues
(
"app.system.session-timeout=1h"
,
"app.system.read-timeout=5s"
).
run
(
assertBinding
(
p
->
{
assertThat
(
p
.
getSessionTimeout
()).
isEqualTo
(
Duration
.
ofMinutes
(
60
));
assertThat
(
p
.
getReadTimeout
()).
isEqualTo
(
Duration
.
ofMillis
(
5000
));
}));
"app.system.read-timeout=5s"
).
run
(
assertBinding
((
properties
)
->
{
assertThat
(
properties
.
getSessionTimeout
())
.
isEqualTo
(
Duration
.
ofMinutes
(
60
));
assertThat
(
properties
.
getReadTimeout
())
.
isEqualTo
(
Duration
.
ofMillis
(
5000
));
}));
}
@Test
public
void
bindWithIso8601Format
()
{
this
.
contextRunner
.
withPropertyValues
(
"app.system.session-timeout=PT15S"
,
"app.system.read-timeout=PT0.5S"
).
run
(
assertBinding
(
p
->
{
assertThat
(
p
.
getSessionTimeout
()).
isEqualTo
(
Duration
.
ofSeconds
(
15
));
assertThat
(
p
.
getReadTimeout
()).
isEqualTo
(
Duration
.
ofMillis
(
500
));
}));
this
.
contextRunner
.
withPropertyValues
(
"app.system.session-timeout=PT15S"
,
"app.system.read-timeout=PT0.5S"
)
.
run
(
assertBinding
((
properties
)
->
{
assertThat
(
properties
.
getSessionTimeout
())
.
isEqualTo
(
Duration
.
ofSeconds
(
15
));
assertThat
(
properties
.
getReadTimeout
())
.
isEqualTo
(
Duration
.
ofMillis
(
500
));
}));
}
private
ContextConsumer
<
AssertableApplicationContext
>
assertBinding
(
Consumer
<
AppSystemProperties
>
appSystemP
roperties
)
{
Consumer
<
AppSystemProperties
>
p
roperties
)
{
return
(
context
)
->
{
assertThat
(
context
).
hasSingleBean
(
AppSystemProperties
.
class
);
appSystemP
roperties
.
accept
(
context
.
getBean
(
AppSystemProperties
.
class
));
p
roperties
.
accept
(
context
.
getBean
(
AppSystemProperties
.
class
));
};
}
...
...
spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/web/client/SampleWebClientConfiguration.java
View file @
3e4da3cc
...
...
@@ -35,11 +35,10 @@ import org.springframework.web.bind.annotation.RestController;
*/
@SpringBootConfiguration
@ImportAutoConfiguration
({
ServletWebServerFactoryAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
,
JacksonAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
})
DispatcherServletAutoConfiguration
.
class
,
JacksonAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
})
class
SampleWebClientConfiguration
{
@RestController
private
static
class
ExampleController
{
...
...
spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/web/client/SampleWebClientTests.java
View file @
3e4da3cc
...
...
@@ -56,9 +56,7 @@ public class SampleWebClientTests {
@Bean
public
RestTemplateBuilder
restTemplateBuilder
()
{
return
new
RestTemplateBuilder
()
.
setConnectTimeout
(
1000
)
.
setReadTimeout
(
1000
);
return
new
RestTemplateBuilder
().
setConnectTimeout
(
1000
).
setReadTimeout
(
1000
);
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/ApplicationPluginActionIntegrationTests.java
View file @
3e4da3cc
/*
* 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.
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java
View file @
3e4da3cc
...
...
@@ -26,8 +26,6 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.function.Consumer
;
import
java.util.function.Function
;
import
java.util.function.Predicate
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.PropertyEditorRegistry
;
...
...
@@ -35,6 +33,7 @@ import org.springframework.beans.SimpleTypeConverter;
import
org.springframework.beans.propertyeditors.FileEditor
;
import
org.springframework.boot.convert.ApplicationConversionService
;
import
org.springframework.core.ResolvableType
;
import
org.springframework.core.convert.ConversionException
;
import
org.springframework.core.convert.ConversionService
;
import
org.springframework.core.convert.TypeDescriptor
;
import
org.springframework.core.convert.converter.ConditionalGenericConverter
;
...
...
@@ -62,16 +61,27 @@ class BindConverter {
BindConverter
(
ConversionService
conversionService
,
Consumer
<
PropertyEditorRegistry
>
propertyEditorInitializer
)
{
Assert
.
notNull
(
conversionService
,
"ConversionService must not be null"
);
this
.
conversionService
=
new
CompositeConversionService
(
new
TypeConverterConversionService
(
propertyEditorInitializer
),
conversionService
);
List
<
ConversionService
>
conversionServices
=
getConversionServices
(
conversionService
,
propertyEditorInitializer
);
this
.
conversionService
=
new
CompositeConversionService
(
conversionServices
);
}
private
List
<
ConversionService
>
getConversionServices
(
ConversionService
conversionService
,
Consumer
<
PropertyEditorRegistry
>
propertyEditorInitializer
)
{
List
<
ConversionService
>
services
=
new
ArrayList
<>();
services
.
add
(
new
TypeConverterConversionService
(
propertyEditorInitializer
));
services
.
add
(
conversionService
);
if
(!(
conversionService
instanceof
ApplicationConversionService
))
{
services
.
add
(
ApplicationConversionService
.
getSharedInstance
());
}
return
services
;
}
public
boolean
canConvert
(
Object
value
,
ResolvableType
type
,
Annotation
...
annotations
)
{
TypeDescriptor
sourceType
=
TypeDescriptor
.
forObject
(
value
);
TypeDescriptor
targetType
=
new
ResolvableTypeDescriptor
(
type
,
annotations
);
return
this
.
conversionService
.
canConvert
(
sourceType
,
targetType
);
return
this
.
conversionService
.
canConvert
(
TypeDescriptor
.
forObject
(
value
),
new
ResolvableTypeDescriptor
(
type
,
annotations
));
}
public
<
T
>
T
convert
(
Object
result
,
Bindable
<
T
>
target
)
{
...
...
@@ -83,9 +93,8 @@ class BindConverter {
if
(
value
==
null
)
{
return
null
;
}
TypeDescriptor
sourceType
=
TypeDescriptor
.
forObject
(
value
);
TypeDescriptor
targetType
=
new
ResolvableTypeDescriptor
(
type
,
annotations
);
return
(
T
)
this
.
conversionService
.
convert
(
value
,
sourceType
,
targetType
);
return
(
T
)
this
.
conversionService
.
convert
(
value
,
TypeDescriptor
.
forObject
(
value
),
new
ResolvableTypeDescriptor
(
type
,
annotations
));
}
/**
...
...
@@ -100,6 +109,62 @@ class BindConverter {
}
/**
* Composite {@link ConversionService} used to call multiple services
*/
static
class
CompositeConversionService
implements
ConversionService
{
private
final
List
<
ConversionService
>
delegates
;
CompositeConversionService
(
List
<
ConversionService
>
delegates
)
{
this
.
delegates
=
delegates
;
}
@Override
public
boolean
canConvert
(
Class
<?>
sourceType
,
Class
<?>
targetType
)
{
Assert
.
notNull
(
targetType
,
"Target type to convert to cannot be null"
);
return
canConvert
(
(
sourceType
!=
null
?
TypeDescriptor
.
valueOf
(
sourceType
)
:
null
),
TypeDescriptor
.
valueOf
(
targetType
));
}
@Override
public
boolean
canConvert
(
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
for
(
ConversionService
service
:
this
.
delegates
)
{
if
(
service
.
canConvert
(
sourceType
,
targetType
))
{
return
true
;
}
}
return
false
;
}
@Override
@SuppressWarnings
(
"unchecked"
)
public
<
T
>
T
convert
(
Object
source
,
Class
<
T
>
targetType
)
{
Assert
.
notNull
(
targetType
,
"Target type to convert to cannot be null"
);
return
(
T
)
convert
(
source
,
TypeDescriptor
.
forObject
(
source
),
TypeDescriptor
.
valueOf
(
targetType
));
}
@Override
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
for
(
int
i
=
0
;
i
<
this
.
delegates
.
size
()
-
1
;
i
++)
{
try
{
ConversionService
delegate
=
this
.
delegates
.
get
(
i
);
if
(
delegate
.
canConvert
(
sourceType
,
targetType
))
{
return
delegate
.
convert
(
source
,
sourceType
,
targetType
);
}
}
catch
(
ConversionException
ex
)
{
}
}
return
this
.
delegates
.
get
(
this
.
delegates
.
size
()
-
1
).
convert
(
source
,
sourceType
,
targetType
);
}
}
/**
* A {@link ConversionService} implementation that delegates to a
* {@link SimpleTypeConverter}. Allows {@link PropertyEditor} based conversion for
...
...
@@ -107,15 +172,18 @@ class BindConverter {
*/
private
static
class
TypeConverterConversionService
extends
GenericConversionService
{
private
SimpleTypeConverter
typeConverter
;
TypeConverterConversionService
(
Consumer
<
PropertyEditorRegistry
>
initializer
)
{
this
.
typeConverter
=
new
SimpleTypeConverter
();
addConverter
(
new
TypeConverterConverter
(
createTypeConverter
(
initializer
)));
ApplicationConversionService
.
addDelimitedStringConverters
(
this
);
}
private
SimpleTypeConverter
createTypeConverter
(
Consumer
<
PropertyEditorRegistry
>
initializer
)
{
SimpleTypeConverter
typeConverter
=
new
SimpleTypeConverter
();
if
(
initializer
!=
null
)
{
initializer
.
accept
(
t
his
.
t
ypeConverter
);
initializer
.
accept
(
typeConverter
);
}
addConverter
(
new
TypeConverterConverter
(
this
.
typeConverter
));
ApplicationConversionService
.
addDelimitedStringConverters
(
this
);
return
typeConverter
;
}
@Override
...
...
@@ -135,9 +203,9 @@ class BindConverter {
*/
private
static
class
TypeConverterConverter
implements
ConditionalGenericConverter
{
private
SimpleTypeConverter
typeConverter
;
private
final
SimpleTypeConverter
typeConverter
;
TypeConverterConverter
(
SimpleTypeConverter
typeConverter
)
{
public
TypeConverterConverter
(
SimpleTypeConverter
typeConverter
)
{
this
.
typeConverter
=
typeConverter
;
}
...
...
@@ -154,18 +222,20 @@ class BindConverter {
@Override
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
this
.
typeConverter
.
convertIfNecessary
(
source
,
targetType
.
getType
());
SimpleTypeConverter
typeConverter
=
this
.
typeConverter
;
return
typeConverter
.
convertIfNecessary
(
source
,
targetType
.
getType
());
}
private
PropertyEditor
getPropertyEditor
(
Class
<?>
type
)
{
SimpleTypeConverter
typeConverter
=
this
.
typeConverter
;
if
(
type
==
null
||
type
==
Object
.
class
||
Collection
.
class
.
isAssignableFrom
(
type
)
||
Map
.
class
.
isAssignableFrom
(
type
))
{
return
null
;
}
PropertyEditor
editor
=
t
his
.
t
ypeConverter
.
getDefaultEditor
(
type
);
PropertyEditor
editor
=
typeConverter
.
getDefaultEditor
(
type
);
if
(
editor
==
null
)
{
editor
=
t
his
.
t
ypeConverter
.
findCustomEditor
(
type
,
null
);
editor
=
typeConverter
.
findCustomEditor
(
type
,
null
);
}
if
(
editor
==
null
&&
String
.
class
!=
type
)
{
editor
=
BeanUtils
.
findEditorByConvention
(
type
);
...
...
@@ -178,66 +248,4 @@ class BindConverter {
}
private
static
final
class
CompositeConversionService
implements
ConversionService
{
private
final
List
<
ConversionService
>
delegates
;
private
CompositeConversionService
(
TypeConverterConversionService
typeConverterConversionService
,
ConversionService
conversionService
)
{
List
<
ConversionService
>
delegates
=
new
ArrayList
<
ConversionService
>();
delegates
.
add
(
typeConverterConversionService
);
delegates
.
add
(
conversionService
);
if
(!(
conversionService
instanceof
ApplicationConversionService
))
{
delegates
.
add
(
ApplicationConversionService
.
getSharedInstance
());
}
this
.
delegates
=
delegates
;
}
@Override
public
boolean
canConvert
(
Class
<?>
sourceType
,
Class
<?>
targetType
)
{
return
canConvert
((
delegate
)
->
delegate
.
canConvert
(
sourceType
,
targetType
));
}
@Override
public
boolean
canConvert
(
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
canConvert
((
delegate
)
->
delegate
.
canConvert
(
sourceType
,
targetType
));
}
private
boolean
canConvert
(
Predicate
<
ConversionService
>
canConvert
)
{
for
(
ConversionService
delegate
:
this
.
delegates
)
{
if
(
canConvert
.
test
(
delegate
))
{
return
true
;
}
}
return
false
;
}
@Override
public
<
T
>
T
convert
(
Object
source
,
Class
<
T
>
targetType
)
{
Class
<?>
sourceType
=
source
.
getClass
();
return
convert
((
delegate
)
->
delegate
.
canConvert
(
sourceType
,
targetType
),
(
delegate
)
->
delegate
.
convert
(
source
,
targetType
));
}
@Override
public
Object
convert
(
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
return
convert
((
delegate
)
->
delegate
.
canConvert
(
sourceType
,
targetType
),
(
delegate
)
->
delegate
.
convert
(
source
,
sourceType
,
targetType
));
}
public
<
T
>
T
convert
(
Predicate
<
ConversionService
>
canConvert
,
Function
<
ConversionService
,
T
>
convert
)
{
for
(
int
i
=
0
;
i
<
this
.
delegates
.
size
()
-
1
;
i
++)
{
ConversionService
delegate
=
this
.
delegates
.
get
(
i
);
if
(
canConvert
.
test
(
delegate
))
{
return
convert
.
apply
(
delegate
);
}
}
return
convert
.
apply
(
this
.
delegates
.
get
(
this
.
delegates
.
size
()
-
1
));
}
}
}
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactoryTests.java
View file @
3e4da3cc
...
...
@@ -157,52 +157,42 @@ public class JettyServletWebServerFactoryTests
@Test
public
void
sslEnabledMultiProtocolsConfiguration
()
{
Ssl
ssl
=
new
Ssl
();
ssl
.
setKeyStore
(
"src/test/resources/test.jks"
);
ssl
.
setKeyStorePassword
(
"secret"
);
ssl
.
setKeyPassword
(
"password"
);
ssl
.
setCiphers
(
new
String
[]
{
"ALPHA"
,
"BRAVO"
,
"CHARLIE"
});
ssl
.
setEnabledProtocols
(
new
String
[]
{
"TLSv1.1"
,
"TLSv1.2"
});
JettyServletWebServerFactory
factory
=
getFactory
();
factory
.
setSsl
(
ssl
);
factory
.
setSsl
(
getSslSettings
(
"TLSv1.1"
,
"TLSv1.2"
));
this
.
webServer
=
factory
.
getWebServer
();
this
.
webServer
.
start
();
JettyWebServer
jettyWebServer
=
(
JettyWebServer
)
this
.
webServer
;
ServerConnector
connector
=
(
ServerConnector
)
jettyWebServer
.
getServer
()
.
getConnectors
()[
0
];
SslConnectionFactory
connectionFactory
=
connector
.
getConnectionFactory
(
SslConnectionFactory
.
class
);
assertThat
(
connectionFactory
.
getSslContextFactory
().
getIncludeProtocols
())
.
isEqualTo
(
new
String
[]
{
"TLSv1.1"
,
"TLSv1.2"
}
);
.
containsExactly
(
"TLSv1.1"
,
"TLSv1.2"
);
}
@Test
public
void
sslEnabledProtocolsConfiguration
()
{
Ssl
ssl
=
new
Ssl
();
ssl
.
setKeyStore
(
"src/test/resources/test.jks"
);
ssl
.
setKeyStorePassword
(
"secret"
);
ssl
.
setKeyPassword
(
"password"
);
ssl
.
setCiphers
(
new
String
[]
{
"ALPHA"
,
"BRAVO"
,
"CHARLIE"
});
ssl
.
setEnabledProtocols
(
new
String
[]
{
"TLSv1.1"
});
JettyServletWebServerFactory
factory
=
getFactory
();
factory
.
setSsl
(
ssl
);
factory
.
setSsl
(
getSslSettings
(
"TLSv1.1"
));
this
.
webServer
=
factory
.
getWebServer
();
this
.
webServer
.
start
();
JettyWebServer
jettyWebServer
=
(
JettyWebServer
)
this
.
webServer
;
ServerConnector
connector
=
(
ServerConnector
)
jettyWebServer
.
getServer
()
.
getConnectors
()[
0
];
SslConnectionFactory
connectionFactory
=
connector
.
getConnectionFactory
(
SslConnectionFactory
.
class
);
assertThat
(
connectionFactory
.
getSslContextFactory
().
getIncludeProtocols
())
.
isEqualTo
(
new
String
[]
{
"TLSv1.1"
});
.
containsExactly
(
"TLSv1.1"
);
}
private
Ssl
getSslSettings
(
String
...
enabledProtocols
)
{
Ssl
ssl
=
new
Ssl
();
ssl
.
setKeyStore
(
"src/test/resources/test.jks"
);
ssl
.
setKeyStorePassword
(
"secret"
);
ssl
.
setKeyPassword
(
"password"
);
ssl
.
setCiphers
(
new
String
[]
{
"ALPHA"
,
"BRAVO"
,
"CHARLIE"
});
ssl
.
setEnabledProtocols
(
enabledProtocols
);
return
ssl
;
}
private
void
assertTimeout
(
JettyServletWebServerFactory
factory
,
int
expected
)
{
...
...
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