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
891dd5a0
Commit
891dd5a0
authored
Aug 03, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
5c1f700c
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
138 additions
and
128 deletions
+138
-128
ConditionalOnEnablednHealthIndicator.java
...e/autoconfigure/ConditionalOnEnablednHealthIndicator.java
+4
-2
LinksEnhancer.java
...ngframework/boot/actuate/autoconfigure/LinksEnhancer.java
+1
-0
OnEnabledHealthIndicatorCondition.java
...uate/autoconfigure/OnEnabledHealthIndicatorCondition.java
+14
-13
SimpleInMemoryRepository.java
...k/boot/actuate/metrics/util/SimpleInMemoryRepository.java
+4
-4
HealthIndicatorAutoConfigurationTests.java
.../autoconfigure/HealthIndicatorAutoConfigurationTests.java
+5
-4
JolokiaAutoConfigurationTests.java
.../actuate/autoconfigure/JolokiaAutoConfigurationTests.java
+2
-0
RabbitProperties.java
...ngframework/boot/autoconfigure/amqp/RabbitProperties.java
+2
-2
DatabaseDriver.java
...ringframework/boot/autoconfigure/jdbc/DatabaseDriver.java
+2
-1
JmsProperties.java
...springframework/boot/autoconfigure/jms/JmsProperties.java
+13
-12
ResourceServerProperties.java
...re/security/oauth2/resource/ResourceServerProperties.java
+1
-1
ThymeleafProperties.java
...ork/boot/autoconfigure/thymeleaf/ThymeleafProperties.java
+4
-4
RabbitAutoConfigurationTests.java
...boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java
+2
-5
JacksonAutoConfigurationTests.java
.../autoconfigure/jackson/JacksonAutoConfigurationTests.java
+3
-3
JmsAutoConfigurationTests.java
...ork/boot/autoconfigure/jms/JmsAutoConfigurationTests.java
+5
-5
OAuth2AutoConfigurationTests.java
...nfigure/security/oauth2/OAuth2AutoConfigurationTests.java
+13
-13
BasicErrorControllerIntegrationTests.java
...toconfigure/web/BasicErrorControllerIntegrationTests.java
+1
-0
howto.adoc
spring-boot-docs/src/main/asciidoc/howto.adoc
+0
-1
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+0
-1
pom.xml
...ot-samples/spring-boot-sample-property-validation/pom.xml
+0
-2
SampleProperties.java
...main/java/sample/propertyvalidation/SampleProperties.java
+3
-2
SamplePropertiesValidator.java
.../sample/propertyvalidation/SamplePropertiesValidator.java
+2
-3
SamplePropertyValidationApplication.java
...opertyvalidation/SamplePropertyValidationApplication.java
+2
-2
SamplePropertyValidationApplicationTests.java
...yvalidation/SamplePropertyValidationApplicationTests.java
+13
-18
LaunchedURLClassLoader.java
...g/springframework/boot/loader/LaunchedURLClassLoader.java
+39
-27
RelaxedDataBinderTests.java
...org/springframework/boot/bind/RelaxedDataBinderTests.java
+3
-3
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ConditionalOnEnablednHealthIndicator.java
View file @
891dd5a0
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
;
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
...
@@ -33,9 +34,10 @@ import org.springframework.context.annotation.Conditional;
...
@@ -33,9 +34,10 @@ import org.springframework.context.annotation.Conditional;
* @author Stephane Nicoll
* @author Stephane Nicoll
* @since 1.3.0
* @since 1.3.0
*/
*/
@Conditional
(
OnEnabledHealthIndicatorCondition
.
class
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
TYPE
,
ElementType
.
METHOD
})
@Target
({
ElementType
.
TYPE
,
ElementType
.
METHOD
})
@Documented
@Conditional
(
OnEnabledHealthIndicatorCondition
.
class
)
public
@interface
ConditionalOnEnablednHealthIndicator
{
public
@interface
ConditionalOnEnablednHealthIndicator
{
/**
/**
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/LinksEnhancer.java
View file @
891dd5a0
...
@@ -66,4 +66,5 @@ class LinksEnhancer {
...
@@ -66,4 +66,5 @@ class LinksEnhancer {
resource
.
add
(
linkTo
(
type
).
slash
(
fullPath
).
withRel
(
rel
));
resource
.
add
(
linkTo
(
type
).
slash
(
fullPath
).
withRel
(
rel
));
}
}
}
}
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEnabledHealthIndicatorCondition.java
View file @
891dd5a0
...
@@ -28,37 +28,38 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
...
@@ -28,37 +28,38 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
* {@link Condition} that checks if a health indicator is enabled.
* {@link Condition} that checks if a health indicator is enabled.
*
*
* @author Stephane Nicoll
* @author Stephane Nicoll
* @since 1.3.0
*/
*/
class
OnEnabledHealthIndicatorCondition
extends
SpringBootCondition
{
class
OnEnabledHealthIndicatorCondition
extends
SpringBootCondition
{
private
static
final
String
ANNOTATION_CLASS
=
ConditionalOnEnablednHealthIndicator
.
class
.
getName
();
@Override
@Override
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
AnnotationAttributes
annotationAttributes
=
AnnotationAttributes
.
fromMap
(
metadata
AnnotationAttributes
annotationAttributes
=
AnnotationAttributes
.
fromMap
(
metadata
.
getAnnotationAttributes
(
ConditionalOnEnablednHealthIndicator
.
class
.
getName
()));
.
getAnnotationAttributes
(
ANNOTATION_CLASS
));
String
endpointName
=
annotationAttributes
.
getString
(
"value"
);
String
endpointName
=
annotationAttributes
.
getString
(
"value"
);
ConditionOutcome
outcome
=
determineHealthIndicatorOutcome
(
endpointName
,
context
);
ConditionOutcome
outcome
=
getHealthIndicatorOutcome
(
context
,
endpointName
);
if
(
outcome
!=
null
)
{
if
(
outcome
!=
null
)
{
return
outcome
;
return
outcome
;
}
}
return
determine
DefaultIndicatorsOutcome
(
context
);
return
get
DefaultIndicatorsOutcome
(
context
);
}
}
private
ConditionOutcome
determineHealthIndicatorOutcome
(
String
endpointName
,
private
ConditionOutcome
getHealthIndicatorOutcome
(
ConditionContext
context
,
ConditionContext
context
)
{
String
endpointName
)
{
RelaxedPropertyResolver
resolver
=
new
RelaxedPropertyResolver
(
RelaxedPropertyResolver
resolver
=
new
RelaxedPropertyResolver
(
context
.
getEnvironment
(),
"management.health."
+
endpointName
+
"."
);
context
.
getEnvironment
(),
"management.health."
+
endpointName
+
"."
);
if
(
resolver
.
containsProperty
(
"enabled"
))
{
if
(
resolver
.
containsProperty
(
"enabled"
))
{
boolean
match
=
resolver
.
getProperty
(
"enabled"
,
Boolean
.
class
,
boolean
match
=
resolver
.
getProperty
(
"enabled"
,
Boolean
.
class
,
true
);
true
);
return
new
ConditionOutcome
(
match
,
"The health indicator "
+
endpointName
return
new
ConditionOutcome
(
match
,
"The health indicator "
+
endpointName
+
+
" is "
+
(
match
?
"enabled"
:
"disabled"
));
" is "
+
(
match
?
"enabled"
:
"disabled"
));
}
}
return
null
;
return
null
;
}
}
private
ConditionOutcome
determine
DefaultIndicatorsOutcome
(
ConditionContext
context
)
{
private
ConditionOutcome
get
DefaultIndicatorsOutcome
(
ConditionContext
context
)
{
RelaxedPropertyResolver
resolver
=
new
RelaxedPropertyResolver
(
RelaxedPropertyResolver
resolver
=
new
RelaxedPropertyResolver
(
context
.
getEnvironment
(),
"management.health.defaults."
);
context
.
getEnvironment
(),
"management.health.defaults."
);
boolean
match
=
Boolean
.
valueOf
(
resolver
.
getProperty
(
"enabled"
,
"true"
));
boolean
match
=
Boolean
.
valueOf
(
resolver
.
getProperty
(
"enabled"
,
"true"
));
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/util/SimpleInMemoryRepository.java
View file @
891dd5a0
...
@@ -36,10 +36,6 @@ public class SimpleInMemoryRepository<T> {
...
@@ -36,10 +36,6 @@ public class SimpleInMemoryRepository<T> {
private
final
ConcurrentMap
<
String
,
Object
>
locks
=
new
ConcurrentReferenceHashMap
<
String
,
Object
>();
private
final
ConcurrentMap
<
String
,
Object
>
locks
=
new
ConcurrentReferenceHashMap
<
String
,
Object
>();
public
interface
Callback
<
T
>
{
T
modify
(
T
current
);
}
public
T
update
(
String
name
,
Callback
<
T
>
callback
)
{
public
T
update
(
String
name
,
Callback
<
T
>
callback
)
{
Object
lock
=
this
.
locks
.
putIfAbsent
(
name
,
new
Object
());
Object
lock
=
this
.
locks
.
putIfAbsent
(
name
,
new
Object
());
if
(
lock
==
null
)
{
if
(
lock
==
null
)
{
...
@@ -101,4 +97,8 @@ public class SimpleInMemoryRepository<T> {
...
@@ -101,4 +97,8 @@ public class SimpleInMemoryRepository<T> {
return
this
.
values
;
return
this
.
values
;
}
}
public
interface
Callback
<
T
>
{
T
modify
(
T
current
);
}
}
}
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java
View file @
891dd5a0
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
;
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
;
import
java.util.Map
;
import
java.util.Map
;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
org.junit.After
;
import
org.junit.After
;
...
@@ -105,16 +106,15 @@ public class HealthIndicatorAutoConfigurationTests {
...
@@ -105,16 +106,15 @@ public class HealthIndicatorAutoConfigurationTests {
@Test
@Test
public
void
defaultHealthIndicatorsDisabledWithCustomOne
()
{
public
void
defaultHealthIndicatorsDisabledWithCustomOne
()
{
this
.
context
.
register
(
CustomHealthIndicator
.
class
,
this
.
context
.
register
(
CustomHealthIndicator
.
class
,
HealthIndicatorAutoConfiguration
.
class
,
HealthIndicatorAutoConfiguration
.
class
,
ManagementServerProperties
.
class
);
ManagementServerProperties
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"management.health.defaults.enabled:false"
);
"management.health.defaults.enabled:false"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
Map
<
String
,
HealthIndicator
>
beans
=
this
.
context
Map
<
String
,
HealthIndicator
>
beans
=
this
.
context
.
getBeansOfType
(
HealthIndicator
.
class
);
.
getBeansOfType
(
HealthIndicator
.
class
);
assertEquals
(
1
,
beans
.
size
());
assertEquals
(
1
,
beans
.
size
());
assertSame
(
this
.
context
.
getBean
(
"customHealthIndicator"
),
beans
.
values
()
.
assertSame
(
this
.
context
.
getBean
(
"customHealthIndicator"
),
beans
.
values
()
iterator
().
next
());
.
iterator
().
next
());
}
}
@Test
@Test
...
@@ -445,6 +445,7 @@ public class HealthIndicatorAutoConfigurationTests {
...
@@ -445,6 +445,7 @@ public class HealthIndicatorAutoConfigurationTests {
}
}
};
};
}
}
}
}
}
}
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/JolokiaAutoConfigurationTests.java
View file @
891dd5a0
...
@@ -135,11 +135,13 @@ public class JolokiaAutoConfigurationTests {
...
@@ -135,11 +135,13 @@ public class JolokiaAutoConfigurationTests {
@Configuration
@Configuration
protected
static
class
EndpointsConfig
extends
Config
{
protected
static
class
EndpointsConfig
extends
Config
{
@Bean
@Bean
public
EndpointHandlerMapping
endpointHandlerMapping
(
public
EndpointHandlerMapping
endpointHandlerMapping
(
Collection
<?
extends
MvcEndpoint
>
endpoints
)
{
Collection
<?
extends
MvcEndpoint
>
endpoints
)
{
return
new
EndpointHandlerMapping
(
endpoints
);
return
new
EndpointHandlerMapping
(
endpoints
);
}
}
}
}
@Configuration
@Configuration
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java
View file @
891dd5a0
...
@@ -306,7 +306,7 @@ public class RabbitProperties {
...
@@ -306,7 +306,7 @@ public class RabbitProperties {
private
Integer
maxConcurrency
;
private
Integer
maxConcurrency
;
/**
/**
* Number of messages to be handled in a single request.
It should be greater than
* Number of messages to be handled in a single request. It should be greater than
* or equal to the transaction size (if used).
* or equal to the transaction size (if used).
*/
*/
private
Integer
prefetch
;
private
Integer
prefetch
;
...
@@ -318,7 +318,7 @@ public class RabbitProperties {
...
@@ -318,7 +318,7 @@ public class RabbitProperties {
private
Integer
transactionSize
;
private
Integer
transactionSize
;
public
boolean
isAutoStartup
()
{
public
boolean
isAutoStartup
()
{
return
autoStartup
;
return
this
.
autoStartup
;
}
}
public
void
setAutoStartup
(
boolean
autoStartup
)
{
public
void
setAutoStartup
(
boolean
autoStartup
)
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DatabaseDriver.java
View file @
891dd5a0
...
@@ -86,7 +86,8 @@ enum DatabaseDriver {
...
@@ -86,7 +86,8 @@ enum DatabaseDriver {
/**
/**
* SQL Server
* SQL Server
*/
*/
SQLSERVER
(
"com.microsoft.sqlserver.jdbc.SQLServerDriver"
,
"com.microsoft.sqlserver.jdbc.SQLServerXADataSource"
);
SQLSERVER
(
"com.microsoft.sqlserver.jdbc.SQLServerDriver"
,
"com.microsoft.sqlserver.jdbc.SQLServerXADataSource"
);
private
final
String
driverClassName
;
private
final
String
driverClassName
;
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java
View file @
891dd5a0
...
@@ -58,7 +58,7 @@ public class JmsProperties {
...
@@ -58,7 +58,7 @@ public class JmsProperties {
}
}
public
Listener
getListener
()
{
public
Listener
getListener
()
{
return
listener
;
return
this
.
listener
;
}
}
public
static
class
Listener
{
public
static
class
Listener
{
...
@@ -69,8 +69,8 @@ public class JmsProperties {
...
@@ -69,8 +69,8 @@ public class JmsProperties {
private
boolean
autoStartup
=
true
;
private
boolean
autoStartup
=
true
;
/**
/**
* Acknowledge mode of the container. By default, the listener is
* Acknowledge mode of the container. By default, the listener is
transacted with
*
transacted with
automatic acknowledgment.
* automatic acknowledgment.
*/
*/
private
AcknowledgeMode
acknowledgeMode
;
private
AcknowledgeMode
acknowledgeMode
;
...
@@ -85,7 +85,7 @@ public class JmsProperties {
...
@@ -85,7 +85,7 @@ public class JmsProperties {
private
Integer
maxConcurrency
;
private
Integer
maxConcurrency
;
public
boolean
isAutoStartup
()
{
public
boolean
isAutoStartup
()
{
return
autoStartup
;
return
this
.
autoStartup
;
}
}
public
void
setAutoStartup
(
boolean
autoStartup
)
{
public
void
setAutoStartup
(
boolean
autoStartup
)
{
...
@@ -93,7 +93,7 @@ public class JmsProperties {
...
@@ -93,7 +93,7 @@ public class JmsProperties {
}
}
public
AcknowledgeMode
getAcknowledgeMode
()
{
public
AcknowledgeMode
getAcknowledgeMode
()
{
return
acknowledgeMode
;
return
this
.
acknowledgeMode
;
}
}
public
void
setAcknowledgeMode
(
AcknowledgeMode
acknowledgeMode
)
{
public
void
setAcknowledgeMode
(
AcknowledgeMode
acknowledgeMode
)
{
...
@@ -120,16 +120,17 @@ public class JmsProperties {
...
@@ -120,16 +120,17 @@ public class JmsProperties {
if
(
this
.
concurrency
==
null
)
{
if
(
this
.
concurrency
==
null
)
{
return
(
this
.
maxConcurrency
!=
null
?
"1-"
+
this
.
maxConcurrency
:
null
);
return
(
this
.
maxConcurrency
!=
null
?
"1-"
+
this
.
maxConcurrency
:
null
);
}
}
return
(
this
.
maxConcurrency
!=
null
?
this
.
concurrency
+
"-"
+
return
(
this
.
maxConcurrency
!=
null
?
this
.
concurrency
+
"-"
this
.
maxConcurrency
:
String
.
valueOf
(
this
.
concurrency
));
+
this
.
maxConcurrency
:
String
.
valueOf
(
this
.
concurrency
));
}
}
}
}
/**
/**
* Translate the acknowledge modes defined on the {@link javax.jms.Session}.
* Translate the acknowledge modes defined on the {@link javax.jms.Session}.
*
*
* <p>{@link javax.jms.Session#SESSION_TRANSACTED} is not defined as we take
* <p>
* care of this already via a call to {@code setSessionTransacted}.
* {@link javax.jms.Session#SESSION_TRANSACTED} is not defined as we take care of this
* already via a call to {@code setSessionTransacted}.
*/
*/
public
enum
AcknowledgeMode
{
public
enum
AcknowledgeMode
{
...
@@ -140,8 +141,8 @@ public class JmsProperties {
...
@@ -140,8 +141,8 @@ public class JmsProperties {
AUTO
(
1
),
AUTO
(
1
),
/**
/**
* Messages are acknowledged once the message listener implementation has
* Messages are acknowledged once the message listener implementation has
called
*
called
{@link javax.jms.Message#acknowledge()}. This mode gives the application
* {@link javax.jms.Message#acknowledge()}. This mode gives the application
* (rather than the JMS provider) complete control over message acknowledgement.
* (rather than the JMS provider) complete control over message acknowledgement.
*/
*/
CLIENT
(
2
),
CLIENT
(
2
),
...
@@ -160,7 +161,7 @@ public class JmsProperties {
...
@@ -160,7 +161,7 @@ public class JmsProperties {
}
}
public
int
getMode
()
{
public
int
getMode
()
{
return
mode
;
return
this
.
mode
;
}
}
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerProperties.java
View file @
891dd5a0
...
@@ -244,7 +244,7 @@ public class ResourceServerProperties implements Validator, BeanFactoryAware {
...
@@ -244,7 +244,7 @@ public class ResourceServerProperties implements Validator, BeanFactoryAware {
}
}
if
(
ResourceServerProperties
.
this
.
tokenInfoUri
!=
null
if
(
ResourceServerProperties
.
this
.
tokenInfoUri
!=
null
&&
ResourceServerProperties
.
this
.
tokenInfoUri
&&
ResourceServerProperties
.
this
.
tokenInfoUri
.
endsWith
(
"/check_token"
))
{
.
endsWith
(
"/check_token"
))
{
return
ResourceServerProperties
.
this
.
userInfoUri
.
replace
(
"/check_token"
,
return
ResourceServerProperties
.
this
.
userInfoUri
.
replace
(
"/check_token"
,
"/token_key"
);
"/token_key"
);
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java
View file @
891dd5a0
...
@@ -74,9 +74,9 @@ public class ThymeleafProperties {
...
@@ -74,9 +74,9 @@ public class ThymeleafProperties {
private
boolean
cache
=
true
;
private
boolean
cache
=
true
;
/**
/**
* Order of the template resolver in the chain. By default, the template resolver
* Order of the template resolver in the chain. By default, the template resolver
is
*
is first in the chain. Order start at 1 and should only be set if you have
*
first in the chain. Order start at 1 and should only be set if you have defined
*
defined
additional "TemplateResolver" beans.
* additional "TemplateResolver" beans.
*/
*/
private
Integer
templateResolverOrder
;
private
Integer
templateResolverOrder
;
...
@@ -160,7 +160,7 @@ public class ThymeleafProperties {
...
@@ -160,7 +160,7 @@ public class ThymeleafProperties {
}
}
public
Integer
getTemplateResolverOrder
()
{
public
Integer
getTemplateResolverOrder
()
{
return
templateResolverOrder
;
return
t
his
.
t
emplateResolverOrder
;
}
}
public
void
setTemplateResolverOrder
(
Integer
templateResolverOrder
)
{
public
void
setTemplateResolverOrder
(
Integer
templateResolverOrder
)
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java
View file @
891dd5a0
...
@@ -23,7 +23,6 @@ import org.junit.After;
...
@@ -23,7 +23,6 @@ import org.junit.After;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.amqp.core.AcknowledgeMode
;
import
org.springframework.amqp.core.AcknowledgeMode
;
import
org.springframework.amqp.core.AmqpAdmin
;
import
org.springframework.amqp.core.AmqpAdmin
;
import
org.springframework.amqp.rabbit.annotation.EnableRabbit
;
import
org.springframework.amqp.rabbit.annotation.EnableRabbit
;
...
@@ -189,8 +188,7 @@ public class RabbitAutoConfigurationTests {
...
@@ -189,8 +188,7 @@ public class RabbitAutoConfigurationTests {
@Test
@Test
public
void
testRabbitListenerContainerFactoryWithCustomSettings
()
{
public
void
testRabbitListenerContainerFactoryWithCustomSettings
()
{
load
(
TestConfiguration
.
class
,
load
(
TestConfiguration
.
class
,
"spring.rabbitmq.listener.autoStartup:false"
,
"spring.rabbitmq.listener.autoStartup:false"
,
"spring.rabbitmq.listener.acknowledgeMode:manual"
,
"spring.rabbitmq.listener.acknowledgeMode:manual"
,
"spring.rabbitmq.listener.concurrency:5"
,
"spring.rabbitmq.listener.concurrency:5"
,
"spring.rabbitmq.listener.maxConcurrency:10"
,
"spring.rabbitmq.listener.maxConcurrency:10"
,
...
@@ -201,8 +199,7 @@ public class RabbitAutoConfigurationTests {
...
@@ -201,8 +199,7 @@ public class RabbitAutoConfigurationTests {
SimpleRabbitListenerContainerFactory
.
class
);
SimpleRabbitListenerContainerFactory
.
class
);
DirectFieldAccessor
dfa
=
new
DirectFieldAccessor
(
rabbitListenerContainerFactory
);
DirectFieldAccessor
dfa
=
new
DirectFieldAccessor
(
rabbitListenerContainerFactory
);
assertEquals
(
false
,
dfa
.
getPropertyValue
(
"autoStartup"
));
assertEquals
(
false
,
dfa
.
getPropertyValue
(
"autoStartup"
));
assertEquals
(
AcknowledgeMode
.
MANUAL
,
assertEquals
(
AcknowledgeMode
.
MANUAL
,
dfa
.
getPropertyValue
(
"acknowledgeMode"
));
dfa
.
getPropertyValue
(
"acknowledgeMode"
));
assertEquals
(
5
,
dfa
.
getPropertyValue
(
"concurrentConsumers"
));
assertEquals
(
5
,
dfa
.
getPropertyValue
(
"concurrentConsumers"
));
assertEquals
(
10
,
dfa
.
getPropertyValue
(
"maxConcurrentConsumers"
));
assertEquals
(
10
,
dfa
.
getPropertyValue
(
"maxConcurrentConsumers"
));
assertEquals
(
40
,
dfa
.
getPropertyValue
(
"prefetchCount"
));
assertEquals
(
40
,
dfa
.
getPropertyValue
(
"prefetchCount"
));
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java
View file @
891dd5a0
...
@@ -76,7 +76,7 @@ import static org.mockito.Mockito.mock;
...
@@ -76,7 +76,7 @@ import static org.mockito.Mockito.mock;
*/
*/
public
class
JacksonAutoConfigurationTests
{
public
class
JacksonAutoConfigurationTests
{
AnnotationConfigApplicationContext
context
;
private
AnnotationConfigApplicationContext
context
;
@Before
@Before
public
void
setUp
()
{
public
void
setUp
()
{
...
@@ -411,8 +411,8 @@ public class JacksonAutoConfigurationTests {
...
@@ -411,8 +411,8 @@ public class JacksonAutoConfigurationTests {
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.jackson.date-format:zzzz"
);
"spring.jackson.date-format:zzzz"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
ObjectMapper
objectMapper
=
this
.
context
ObjectMapper
objectMapper
=
this
.
context
.
getBean
(
.
getBean
(
Jackson2ObjectMapperBuilder
.
class
).
build
();
Jackson2ObjectMapperBuilder
.
class
).
build
();
DateTime
dateTime
=
new
DateTime
(
1436966242231L
,
DateTimeZone
.
UTC
);
DateTime
dateTime
=
new
DateTime
(
1436966242231L
,
DateTimeZone
.
UTC
);
assertEquals
(
"\"Koordinierte Universalzeit\""
,
assertEquals
(
"\"Koordinierte Universalzeit\""
,
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsAutoConfigurationTests.java
View file @
891dd5a0
...
@@ -146,8 +146,7 @@ public class JmsAutoConfigurationTests {
...
@@ -146,8 +146,7 @@ public class JmsAutoConfigurationTests {
@Test
@Test
public
void
testJmsListenerContainerFactoryWithCustomSettings
()
{
public
void
testJmsListenerContainerFactoryWithCustomSettings
()
{
load
(
EnableJmsConfiguration
.
class
,
load
(
EnableJmsConfiguration
.
class
,
"spring.jms.listener.autoStartup=false"
,
"spring.jms.listener.autoStartup=false"
,
"spring.jms.listener.acknowledgeMode=client"
,
"spring.jms.listener.acknowledgeMode=client"
,
"spring.jms.listener.concurrency=2"
,
"spring.jms.listener.concurrency=2"
,
"spring.jms.listener.maxConcurrency=10"
);
"spring.jms.listener.maxConcurrency=10"
);
...
@@ -155,10 +154,11 @@ public class JmsAutoConfigurationTests {
...
@@ -155,10 +154,11 @@ public class JmsAutoConfigurationTests {
.
getBean
(
"jmsListenerContainerFactory"
,
JmsListenerContainerFactory
.
class
);
.
getBean
(
"jmsListenerContainerFactory"
,
JmsListenerContainerFactory
.
class
);
assertEquals
(
DefaultJmsListenerContainerFactory
.
class
,
assertEquals
(
DefaultJmsListenerContainerFactory
.
class
,
jmsListenerContainerFactory
.
getClass
());
jmsListenerContainerFactory
.
getClass
());
DefaultMessageListenerContainer
listenerContainer
=
((
DefaultJmsListenerContainerFactory
)
DefaultMessageListenerContainer
listenerContainer
=
((
DefaultJmsListenerContainerFactory
)
jmsListenerContainerFactory
)
jmsListenerContainerFactory
)
.
createListenerContainer
(
mock
(
JmsListenerEndpoint
.
class
));
.
createListenerContainer
(
mock
(
JmsListenerEndpoint
.
class
));
assertEquals
(
false
,
listenerContainer
.
isAutoStartup
());
assertEquals
(
false
,
listenerContainer
.
isAutoStartup
());
assertEquals
(
Session
.
CLIENT_ACKNOWLEDGE
,
listenerContainer
.
getSessionAcknowledgeMode
());
assertEquals
(
Session
.
CLIENT_ACKNOWLEDGE
,
listenerContainer
.
getSessionAcknowledgeMode
());
assertEquals
(
2
,
listenerContainer
.
getConcurrentConsumers
());
assertEquals
(
2
,
listenerContainer
.
getConcurrentConsumers
());
assertEquals
(
10
,
listenerContainer
.
getMaxConcurrentConsumers
());
assertEquals
(
10
,
listenerContainer
.
getMaxConcurrentConsumers
());
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java
View file @
891dd5a0
...
@@ -16,9 +16,6 @@
...
@@ -16,9 +16,6 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
security
.
oauth2
;
package
org
.
springframework
.
boot
.
autoconfigure
.
security
.
oauth2
;
import
static
org
.
hamcrest
.
CoreMatchers
.
equalTo
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
java.net.URI
;
import
java.net.URI
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
...
@@ -94,6 +91,9 @@ import org.springframework.web.client.RestTemplate;
...
@@ -94,6 +91,9 @@ import org.springframework.web.client.RestTemplate;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
static
org
.
hamcrest
.
CoreMatchers
.
equalTo
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
/**
/**
* Verify Spring Security OAuth2 auto-configuration secures end points properly, accepts
* Verify Spring Security OAuth2 auto-configuration secures end points properly, accepts
* environmental overrides, and also backs off in the presence of other
* environmental overrides, and also backs off in the presence of other
...
@@ -358,9 +358,9 @@ public class OAuth2AutoConfigurationTests {
...
@@ -358,9 +358,9 @@ public class OAuth2AutoConfigurationTests {
@Configuration
@Configuration
@Import
({
UseFreePortEmbeddedContainerConfiguration
.
class
,
@Import
({
UseFreePortEmbeddedContainerConfiguration
.
class
,
SecurityAutoConfiguration
.
class
,
ServerPropertiesAutoConfiguration
.
class
,
SecurityAutoConfiguration
.
class
,
ServerPropertiesAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
,
OAuth2AutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
,
OAuth2AutoConfiguration
.
class
,
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
})
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
})
protected
static
class
MinimalSecureWebApplication
{
protected
static
class
MinimalSecureWebApplication
{
}
}
...
@@ -396,7 +396,7 @@ public class OAuth2AutoConfigurationTests {
...
@@ -396,7 +396,7 @@ public class OAuth2AutoConfigurationTests {
@EnableResourceServer
@EnableResourceServer
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
protected
static
class
AuthorizationAndResourceServerConfiguration
extends
protected
static
class
AuthorizationAndResourceServerConfiguration
extends
TestSecurityConfiguration
{
TestSecurityConfiguration
{
}
}
...
@@ -419,7 +419,7 @@ public class OAuth2AutoConfigurationTests {
...
@@ -419,7 +419,7 @@ public class OAuth2AutoConfigurationTests {
@Configuration
@Configuration
@EnableAuthorizationServer
@EnableAuthorizationServer
protected
static
class
AuthorizationServerConfiguration
extends
protected
static
class
AuthorizationServerConfiguration
extends
TestSecurityConfiguration
{
TestSecurityConfiguration
{
}
}
...
@@ -474,7 +474,7 @@ public class OAuth2AutoConfigurationTests {
...
@@ -474,7 +474,7 @@ public class OAuth2AutoConfigurationTests {
@Override
@Override
public
void
configure
(
HttpSecurity
http
)
throws
Exception
{
public
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
authorizeRequests
().
anyRequest
().
authenticated
().
and
().
httpBasic
().
and
()
http
.
authorizeRequests
().
anyRequest
().
authenticated
().
and
().
httpBasic
().
and
()
.
csrf
().
disable
();
.
csrf
().
disable
();
}
}
}
}
...
@@ -482,7 +482,7 @@ public class OAuth2AutoConfigurationTests {
...
@@ -482,7 +482,7 @@ public class OAuth2AutoConfigurationTests {
@Configuration
@Configuration
@EnableAuthorizationServer
@EnableAuthorizationServer
protected
static
class
CustomAuthorizationServer
extends
protected
static
class
CustomAuthorizationServer
extends
AuthorizationServerConfigurerAdapter
{
AuthorizationServerConfigurerAdapter
{
@Autowired
@Autowired
private
AuthenticationManager
authenticationManager
;
private
AuthenticationManager
authenticationManager
;
...
@@ -502,9 +502,9 @@ public class OAuth2AutoConfigurationTests {
...
@@ -502,9 +502,9 @@ public class OAuth2AutoConfigurationTests {
@Override
@Override
public
void
configure
(
ClientDetailsServiceConfigurer
clients
)
throws
Exception
{
public
void
configure
(
ClientDetailsServiceConfigurer
clients
)
throws
Exception
{
clients
.
inMemory
().
withClient
(
"client"
).
secret
(
"secret"
)
clients
.
inMemory
().
withClient
(
"client"
).
secret
(
"secret"
)
.
resourceIds
(
"resource-id"
).
authorizedGrantTypes
(
"password"
)
.
resourceIds
(
"resource-id"
).
authorizedGrantTypes
(
"password"
)
.
authorities
(
"USER"
).
scopes
(
"read"
)
.
authorities
(
"USER"
).
scopes
(
"read"
)
.
redirectUris
(
"http://localhost:8080"
);
.
redirectUris
(
"http://localhost:8080"
);
}
}
@Override
@Override
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerIntegrationTests.java
View file @
891dd5a0
...
@@ -181,6 +181,7 @@ public class BasicErrorControllerIntegrationTests {
...
@@ -181,6 +181,7 @@ public class BasicErrorControllerIntegrationTests {
public
NoReasonExpectedException
(
String
message
)
{
public
NoReasonExpectedException
(
String
message
)
{
super
(
message
);
super
(
message
);
}
}
}
}
}
}
...
...
spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
891dd5a0
...
@@ -1476,7 +1476,6 @@ respectively.
...
@@ -1476,7 +1476,6 @@ respectively.
[[howto-use-exposing-spring-data-repositories-rest-endpoint]]
[[howto-use-exposing-spring-data-repositories-rest-endpoint]]
=== Expose Spring Data repositories as REST endpoint
=== Expose Spring Data repositories as REST endpoint
Spring Data REST can expose the `Repository` implementations as REST endpoints for you as
Spring Data REST can expose the `Repository` implementations as REST endpoints for you as
long as Spring MVC has been enabled for the application.
long as Spring MVC has been enabled for the application.
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
891dd5a0
...
@@ -781,7 +781,6 @@ annotations to your `@ConfigurationProperties` class:
...
@@ -781,7 +781,6 @@ annotations to your `@ConfigurationProperties` class:
}
}
----
----
In order to validate values of nested properties, you must annotate the associated field
In order to validate values of nested properties, you must annotate the associated field
as `@Valid` to trigger its validation. For example, building upon the above
as `@Valid` to trigger its validation. For example, building upon the above
`ConnectionSettings` example:
`ConnectionSettings` example:
...
...
spring-boot-samples/spring-boot-sample-property-validation/pom.xml
View file @
891dd5a0
...
@@ -23,13 +23,11 @@
...
@@ -23,13 +23,11 @@
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-configuration-processor
</artifactId>
<artifactId>
spring-boot-configuration-processor
</artifactId>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<artifactId>
spring-boot-starter-test
</artifactId>
...
...
spring-boot-samples/spring-boot-sample-property-validation/src/main/java/sample/propertyvalidation/SampleProperties.java
View file @
891dd5a0
...
@@ -34,7 +34,7 @@ public class SampleProperties {
...
@@ -34,7 +34,7 @@ public class SampleProperties {
private
Integer
port
=
8080
;
private
Integer
port
=
8080
;
public
String
getHost
()
{
public
String
getHost
()
{
return
host
;
return
this
.
host
;
}
}
public
void
setHost
(
String
host
)
{
public
void
setHost
(
String
host
)
{
...
@@ -42,10 +42,11 @@ public class SampleProperties {
...
@@ -42,10 +42,11 @@ public class SampleProperties {
}
}
public
Integer
getPort
()
{
public
Integer
getPort
()
{
return
port
;
return
this
.
port
;
}
}
public
void
setPort
(
Integer
port
)
{
public
void
setPort
(
Integer
port
)
{
this
.
port
=
port
;
this
.
port
=
port
;
}
}
}
}
spring-boot-samples/spring-boot-sample-property-validation/src/main/java/sample/propertyvalidation/SamplePropertiesValidator.java
View file @
891dd5a0
...
@@ -35,10 +35,9 @@ public class SamplePropertiesValidator implements Validator {
...
@@ -35,10 +35,9 @@ public class SamplePropertiesValidator implements Validator {
public
void
validate
(
Object
o
,
Errors
errors
)
{
public
void
validate
(
Object
o
,
Errors
errors
)
{
ValidationUtils
.
rejectIfEmpty
(
errors
,
"host"
,
"host.empty"
);
ValidationUtils
.
rejectIfEmpty
(
errors
,
"host"
,
"host.empty"
);
ValidationUtils
.
rejectIfEmpty
(
errors
,
"port"
,
"port.empty"
);
ValidationUtils
.
rejectIfEmpty
(
errors
,
"port"
,
"port.empty"
);
SampleProperties
properties
=
(
SampleProperties
)
o
;
SampleProperties
properties
=
(
SampleProperties
)
o
;
if
(
properties
.
getHost
()
!=
null
&&
if
(
properties
.
getHost
()
!=
null
!
pattern
.
matcher
(
properties
.
getHost
()).
matches
())
{
&&
!
this
.
pattern
.
matcher
(
properties
.
getHost
()).
matches
())
{
errors
.
rejectValue
(
"host"
,
"Invalid host"
);
errors
.
rejectValue
(
"host"
,
"Invalid host"
);
}
}
}
}
...
...
spring-boot-samples/spring-boot-sample-property-validation/src/main/java/sample/propertyvalidation/SamplePropertyValidationApplication.java
View file @
891dd5a0
...
@@ -52,8 +52,8 @@ public class SamplePropertyValidationApplication {
...
@@ -52,8 +52,8 @@ public class SamplePropertyValidationApplication {
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
SpringApplicationBuilder
(
SamplePropertyValidationApplication
.
class
)
new
SpringApplicationBuilder
(
SamplePropertyValidationApplication
.
class
)
.
profiles
(
.
profiles
(
"app"
).
run
(
args
);
"app"
).
run
(
args
);
}
}
}
}
spring-boot-samples/spring-boot-sample-property-validation/src/test/java/sample/propertyvalidation/SamplePropertyValidationApplicationTests.java
View file @
891dd5a0
...
@@ -20,7 +20,6 @@ import org.junit.After;
...
@@ -20,7 +20,6 @@ import org.junit.After;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.boot.autoconfigure.web.ServerProperties
;
import
org.springframework.boot.autoconfigure.web.ServerProperties
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
...
@@ -43,16 +42,15 @@ public class SamplePropertyValidationApplicationTests {
...
@@ -43,16 +42,15 @@ public class SamplePropertyValidationApplicationTests {
@After
@After
public
void
closeContext
()
{
public
void
closeContext
()
{
context
.
close
();
this
.
context
.
close
();
}
}
@Test
@Test
public
void
bindValidProperties
()
{
public
void
bindValidProperties
()
{
this
.
context
.
register
(
SamplePropertyValidationApplication
.
class
);
this
.
context
.
register
(
SamplePropertyValidationApplication
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"sample.host:192.168.0.1"
,
"sample.
host:192.168.0.1"
,
"sample.
port:9090"
);
"sample.port:9090"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
SampleProperties
properties
=
this
.
context
.
getBean
(
SampleProperties
.
class
);
SampleProperties
properties
=
this
.
context
.
getBean
(
SampleProperties
.
class
);
assertEquals
(
"192.168.0.1"
,
properties
.
getHost
());
assertEquals
(
"192.168.0.1"
,
properties
.
getHost
());
assertEquals
(
Integer
.
valueOf
(
9090
),
properties
.
getPort
());
assertEquals
(
Integer
.
valueOf
(
9090
),
properties
.
getPort
());
...
@@ -61,32 +59,29 @@ public class SamplePropertyValidationApplicationTests {
...
@@ -61,32 +59,29 @@ public class SamplePropertyValidationApplicationTests {
@Test
@Test
public
void
bindInvalidHost
()
{
public
void
bindInvalidHost
()
{
this
.
context
.
register
(
SamplePropertyValidationApplication
.
class
);
this
.
context
.
register
(
SamplePropertyValidationApplication
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"sample.host:xxxxxx"
,
"sample.host:xxxxxx"
,
"sample.port:9090"
);
"sample.port:9090"
);
this
.
thrown
.
expect
(
BeanCreationException
.
class
);
thrown
.
expect
(
BeanCreationException
.
class
);
this
.
thrown
.
expectMessage
(
"xxxxxx"
);
thrown
.
expectMessage
(
"xxxxxx"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
}
}
@Test
@Test
public
void
bindNullHost
()
{
public
void
bindNullHost
()
{
this
.
context
.
register
(
SamplePropertyValidationApplication
.
class
);
this
.
context
.
register
(
SamplePropertyValidationApplication
.
class
);
this
.
thrown
.
expect
(
BeanCreationException
.
class
);
thrown
.
expect
(
BeanCreationException
.
class
);
this
.
thrown
.
expectMessage
(
"null"
);
thrown
.
expectMessage
(
"null"
);
this
.
thrown
.
expectMessage
(
"host"
);
thrown
.
expectMessage
(
"host"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
}
}
@Test
@Test
public
void
validatorOnlyCalledOnSupportedClass
()
{
public
void
validatorOnlyCalledOnSupportedClass
()
{
this
.
context
.
register
(
SamplePropertyValidationApplication
.
class
);
this
.
context
.
register
(
SamplePropertyValidationApplication
.
class
);
this
.
context
.
register
(
ServerProperties
.
class
);
// our validator will not apply
here
this
.
context
.
register
(
ServerProperties
.
class
);
// our validator will not apply
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"sample.host:192.168.0.1"
,
"sample.
host:192.168.0.1"
,
"sample.
port:9090"
);
"sample.port:9090"
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
SampleProperties
properties
=
this
.
context
.
getBean
(
SampleProperties
.
class
);
SampleProperties
properties
=
this
.
context
.
getBean
(
SampleProperties
.
class
);
assertEquals
(
"192.168.0.1"
,
properties
.
getHost
());
assertEquals
(
"192.168.0.1"
,
properties
.
getHost
());
assertEquals
(
Integer
.
valueOf
(
9090
),
properties
.
getPort
());
assertEquals
(
Integer
.
valueOf
(
9090
),
properties
.
getPort
());
...
...
spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java
View file @
891dd5a0
...
@@ -101,33 +101,8 @@ public class LaunchedURLClassLoader extends URLClassLoader {
...
@@ -101,33 +101,8 @@ public class LaunchedURLClassLoader extends URLClassLoader {
if
(
this
.
rootClassLoader
==
null
)
{
if
(
this
.
rootClassLoader
==
null
)
{
return
findResources
(
name
);
return
findResources
(
name
);
}
}
return
new
ResourceEnumeration
(
this
.
rootClassLoader
.
getResources
(
name
),
final
Enumeration
<
URL
>
rootResources
=
this
.
rootClassLoader
.
getResources
(
name
);
findResources
(
name
));
final
Enumeration
<
URL
>
localResources
=
findResources
(
name
);
return
new
Enumeration
<
URL
>()
{
@Override
public
boolean
hasMoreElements
()
{
try
{
Handler
.
setUseFastConnectionExceptions
(
true
);
return
rootResources
.
hasMoreElements
()
||
localResources
.
hasMoreElements
();
}
finally
{
Handler
.
setUseFastConnectionExceptions
(
false
);
}
}
@Override
public
URL
nextElement
()
{
if
(
rootResources
.
hasMoreElements
())
{
return
rootResources
.
nextElement
();
}
return
localResources
.
nextElement
();
}
};
}
}
/**
/**
...
@@ -267,4 +242,41 @@ public class LaunchedURLClassLoader extends URLClassLoader {
...
@@ -267,4 +242,41 @@ public class LaunchedURLClassLoader extends URLClassLoader {
}
}
/**
* {@link Enumeration} implementation used for {@code getResources()}.
*/
private
static
class
ResourceEnumeration
implements
Enumeration
<
URL
>
{
private
final
Enumeration
<
URL
>
rootResources
;
private
final
Enumeration
<
URL
>
localResources
;
public
ResourceEnumeration
(
Enumeration
<
URL
>
rootResources
,
Enumeration
<
URL
>
localResources
)
{
this
.
rootResources
=
rootResources
;
this
.
localResources
=
localResources
;
}
@Override
public
boolean
hasMoreElements
()
{
try
{
Handler
.
setUseFastConnectionExceptions
(
true
);
return
this
.
rootResources
.
hasMoreElements
()
||
this
.
localResources
.
hasMoreElements
();
}
finally
{
Handler
.
setUseFastConnectionExceptions
(
false
);
}
}
@Override
public
URL
nextElement
()
{
if
(
this
.
rootResources
.
hasMoreElements
())
{
return
this
.
rootResources
.
nextElement
();
}
return
this
.
localResources
.
nextElement
();
}
};
}
}
spring-boot/src/test/java/org/springframework/boot/bind/RelaxedDataBinderTests.java
View file @
891dd5a0
...
@@ -355,11 +355,11 @@ public class RelaxedDataBinderTests {
...
@@ -355,11 +355,11 @@ public class RelaxedDataBinderTests {
bind
(
target
,
"nested.foo: bar.key\n"
+
"nested[bar.key].spam: bucket\n"
bind
(
target
,
"nested.foo: bar.key\n"
+
"nested[bar.key].spam: bucket\n"
+
"nested[bar.key].value: 123\nnested[bar.key].foo: crap"
);
+
"nested[bar.key].value: 123\nnested[bar.key].foo: crap"
);
assertEquals
(
2
,
target
.
getNested
().
size
());
assertEquals
(
2
,
target
.
getNested
().
size
());
Map
<
String
,
Object
>
nestedMap
=
(
Map
<
String
,
Object
>)
target
.
getNested
().
get
(
"bar.key"
);
Map
<
String
,
Object
>
nestedMap
=
(
Map
<
String
,
Object
>)
target
.
getNested
().
get
(
"bar.key"
);
assertNotNull
(
"nested map should be registered with 'bar.key'"
,
nestedMap
);
assertNotNull
(
"nested map should be registered with 'bar.key'"
,
nestedMap
);
assertEquals
(
3
,
nestedMap
.
size
());
assertEquals
(
3
,
nestedMap
.
size
());
assertEquals
(
"123"
,
assertEquals
(
"123"
,
nestedMap
.
get
(
"value"
));
nestedMap
.
get
(
"value"
));
assertEquals
(
"bar.key"
,
target
.
getNested
().
get
(
"foo"
));
assertEquals
(
"bar.key"
,
target
.
getNested
().
get
(
"foo"
));
assertFalse
(
target
.
getNested
().
containsValue
(
target
.
getNested
()));
assertFalse
(
target
.
getNested
().
containsValue
(
target
.
getNested
()));
}
}
...
...
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