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 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
...
...
@@ -33,9 +34,10 @@ import org.springframework.context.annotation.Conditional;
* @author Stephane Nicoll
* @since 1.3.0
*/
@Conditional
(
OnEnabledHealthIndicatorCondition
.
class
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
TYPE
,
ElementType
.
METHOD
})
@Target
({
ElementType
.
TYPE
,
ElementType
.
METHOD
})
@Documented
@Conditional
(
OnEnabledHealthIndicatorCondition
.
class
)
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 {
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;
* {@link Condition} that checks if a health indicator is enabled.
*
* @author Stephane Nicoll
* @since 1.3.0
*/
class
OnEnabledHealthIndicatorCondition
extends
SpringBootCondition
{
private
static
final
String
ANNOTATION_CLASS
=
ConditionalOnEnablednHealthIndicator
.
class
.
getName
();
@Override
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
AnnotationAttributes
annotationAttributes
=
AnnotationAttributes
.
fromMap
(
metadata
.
getAnnotationAttributes
(
ConditionalOnEnablednHealthIndicator
.
class
.
getName
()));
.
getAnnotationAttributes
(
ANNOTATION_CLASS
));
String
endpointName
=
annotationAttributes
.
getString
(
"value"
);
ConditionOutcome
outcome
=
determineHealthIndicatorOutcome
(
endpointName
,
context
);
ConditionOutcome
outcome
=
getHealthIndicatorOutcome
(
context
,
endpointName
);
if
(
outcome
!=
null
)
{
return
outcome
;
}
return
determine
DefaultIndicatorsOutcome
(
context
);
return
get
DefaultIndicatorsOutcome
(
context
);
}
private
ConditionOutcome
determineHealthIndicatorOutcome
(
String
endpointName
,
ConditionContext
context
)
{
private
ConditionOutcome
getHealthIndicatorOutcome
(
ConditionContext
context
,
String
endpointName
)
{
RelaxedPropertyResolver
resolver
=
new
RelaxedPropertyResolver
(
context
.
getEnvironment
(),
"management.health."
+
endpointName
+
"."
);
if
(
resolver
.
containsProperty
(
"enabled"
))
{
boolean
match
=
resolver
.
getProperty
(
"enabled"
,
Boolean
.
class
,
true
);
return
new
ConditionOutcome
(
match
,
"The health indicator "
+
endpointName
+
" is "
+
(
match
?
"enabled"
:
"disabled"
));
boolean
match
=
resolver
.
getProperty
(
"enabled"
,
Boolean
.
class
,
true
);
return
new
ConditionOutcome
(
match
,
"The health indicator "
+
endpointName
+
" is "
+
(
match
?
"enabled"
:
"disabled"
));
}
return
null
;
}
private
ConditionOutcome
determine
DefaultIndicatorsOutcome
(
ConditionContext
context
)
{
private
ConditionOutcome
get
DefaultIndicatorsOutcome
(
ConditionContext
context
)
{
RelaxedPropertyResolver
resolver
=
new
RelaxedPropertyResolver
(
context
.
getEnvironment
(),
"management.health.defaults."
);
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> {
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
)
{
Object
lock
=
this
.
locks
.
putIfAbsent
(
name
,
new
Object
());
if
(
lock
==
null
)
{
...
...
@@ -101,4 +97,8 @@ public class SimpleInMemoryRepository<T> {
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 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
;
import
java.util.Map
;
import
javax.sql.DataSource
;
import
org.junit.After
;
...
...
@@ -105,16 +106,15 @@ public class HealthIndicatorAutoConfigurationTests {
@Test
public
void
defaultHealthIndicatorsDisabledWithCustomOne
()
{
this
.
context
.
register
(
CustomHealthIndicator
.
class
,
HealthIndicatorAutoConfiguration
.
class
,
ManagementServerProperties
.
class
);
HealthIndicatorAutoConfiguration
.
class
,
ManagementServerProperties
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"management.health.defaults.enabled:false"
);
this
.
context
.
refresh
();
Map
<
String
,
HealthIndicator
>
beans
=
this
.
context
.
getBeansOfType
(
HealthIndicator
.
class
);
assertEquals
(
1
,
beans
.
size
());
assertSame
(
this
.
context
.
getBean
(
"customHealthIndicator"
),
beans
.
values
()
.
iterator
().
next
());
assertSame
(
this
.
context
.
getBean
(
"customHealthIndicator"
),
beans
.
values
()
.
iterator
().
next
());
}
@Test
...
...
@@ -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 {
@Configuration
protected
static
class
EndpointsConfig
extends
Config
{
@Bean
public
EndpointHandlerMapping
endpointHandlerMapping
(
Collection
<?
extends
MvcEndpoint
>
endpoints
)
{
return
new
EndpointHandlerMapping
(
endpoints
);
}
}
@Configuration
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java
View file @
891dd5a0
...
...
@@ -306,7 +306,7 @@ public class RabbitProperties {
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).
*/
private
Integer
prefetch
;
...
...
@@ -318,7 +318,7 @@ public class RabbitProperties {
private
Integer
transactionSize
;
public
boolean
isAutoStartup
()
{
return
autoStartup
;
return
this
.
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 {
/**
* 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
;
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java
View file @
891dd5a0
...
...
@@ -58,7 +58,7 @@ public class JmsProperties {
}
public
Listener
getListener
()
{
return
listener
;
return
this
.
listener
;
}
public
static
class
Listener
{
...
...
@@ -69,8 +69,8 @@ public class JmsProperties {
private
boolean
autoStartup
=
true
;
/**
* Acknowledge mode of the container. By default, the listener is
*
transacted with
automatic acknowledgment.
* Acknowledge mode of the container. By default, the listener is
transacted with
* automatic acknowledgment.
*/
private
AcknowledgeMode
acknowledgeMode
;
...
...
@@ -85,7 +85,7 @@ public class JmsProperties {
private
Integer
maxConcurrency
;
public
boolean
isAutoStartup
()
{
return
autoStartup
;
return
this
.
autoStartup
;
}
public
void
setAutoStartup
(
boolean
autoStartup
)
{
...
...
@@ -93,7 +93,7 @@ public class JmsProperties {
}
public
AcknowledgeMode
getAcknowledgeMode
()
{
return
acknowledgeMode
;
return
this
.
acknowledgeMode
;
}
public
void
setAcknowledgeMode
(
AcknowledgeMode
acknowledgeMode
)
{
...
...
@@ -120,16 +120,17 @@ public class JmsProperties {
if
(
this
.
concurrency
==
null
)
{
return
(
this
.
maxConcurrency
!=
null
?
"1-"
+
this
.
maxConcurrency
:
null
);
}
return
(
this
.
maxConcurrency
!=
null
?
this
.
concurrency
+
"-"
+
this
.
maxConcurrency
:
String
.
valueOf
(
this
.
concurrency
));
return
(
this
.
maxConcurrency
!=
null
?
this
.
concurrency
+
"-"
+
this
.
maxConcurrency
:
String
.
valueOf
(
this
.
concurrency
));
}
}
/**
* Translate the acknowledge modes defined on the {@link javax.jms.Session}.
*
* <p>{@link javax.jms.Session#SESSION_TRANSACTED} is not defined as we take
* care of this already via a call to {@code setSessionTransacted}.
* <p>
* {@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
{
...
...
@@ -140,8 +141,8 @@ public class JmsProperties {
AUTO
(
1
),
/**
* Messages are acknowledged once the message listener implementation has
*
called
{@link javax.jms.Message#acknowledge()}. This mode gives the application
* Messages are acknowledged once the message listener implementation has
called
* {@link javax.jms.Message#acknowledge()}. This mode gives the application
* (rather than the JMS provider) complete control over message acknowledgement.
*/
CLIENT
(
2
),
...
...
@@ -160,7 +161,7 @@ public class JmsProperties {
}
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 {
}
if
(
ResourceServerProperties
.
this
.
tokenInfoUri
!=
null
&&
ResourceServerProperties
.
this
.
tokenInfoUri
.
endsWith
(
"/check_token"
))
{
.
endsWith
(
"/check_token"
))
{
return
ResourceServerProperties
.
this
.
userInfoUri
.
replace
(
"/check_token"
,
"/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 {
private
boolean
cache
=
true
;
/**
* Order of the template resolver in the chain. By default, the template resolver
*
is first in the chain. Order start at 1 and should only be set if you have
*
defined
additional "TemplateResolver" beans.
* Order of the template resolver in the chain. By default, the template resolver
is
*
first in the chain. Order start at 1 and should only be set if you have defined
* additional "TemplateResolver" beans.
*/
private
Integer
templateResolverOrder
;
...
...
@@ -160,7 +160,7 @@ public class ThymeleafProperties {
}
public
Integer
getTemplateResolverOrder
()
{
return
templateResolverOrder
;
return
t
his
.
t
emplateResolverOrder
;
}
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;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.amqp.core.AcknowledgeMode
;
import
org.springframework.amqp.core.AmqpAdmin
;
import
org.springframework.amqp.rabbit.annotation.EnableRabbit
;
...
...
@@ -189,8 +188,7 @@ public class RabbitAutoConfigurationTests {
@Test
public
void
testRabbitListenerContainerFactoryWithCustomSettings
()
{
load
(
TestConfiguration
.
class
,
"spring.rabbitmq.listener.autoStartup:false"
,
load
(
TestConfiguration
.
class
,
"spring.rabbitmq.listener.autoStartup:false"
,
"spring.rabbitmq.listener.acknowledgeMode:manual"
,
"spring.rabbitmq.listener.concurrency:5"
,
"spring.rabbitmq.listener.maxConcurrency:10"
,
...
...
@@ -201,8 +199,7 @@ public class RabbitAutoConfigurationTests {
SimpleRabbitListenerContainerFactory
.
class
);
DirectFieldAccessor
dfa
=
new
DirectFieldAccessor
(
rabbitListenerContainerFactory
);
assertEquals
(
false
,
dfa
.
getPropertyValue
(
"autoStartup"
));
assertEquals
(
AcknowledgeMode
.
MANUAL
,
dfa
.
getPropertyValue
(
"acknowledgeMode"
));
assertEquals
(
AcknowledgeMode
.
MANUAL
,
dfa
.
getPropertyValue
(
"acknowledgeMode"
));
assertEquals
(
5
,
dfa
.
getPropertyValue
(
"concurrentConsumers"
));
assertEquals
(
10
,
dfa
.
getPropertyValue
(
"maxConcurrentConsumers"
));
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;
*/
public
class
JacksonAutoConfigurationTests
{
AnnotationConfigApplicationContext
context
;
private
AnnotationConfigApplicationContext
context
;
@Before
public
void
setUp
()
{
...
...
@@ -411,8 +411,8 @@ public class JacksonAutoConfigurationTests {
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.jackson.date-format:zzzz"
);
this
.
context
.
refresh
();
ObjectMapper
objectMapper
=
this
.
context
.
getBean
(
Jackson2ObjectMapperBuilder
.
class
).
build
();
ObjectMapper
objectMapper
=
this
.
context
.
getBean
(
Jackson2ObjectMapperBuilder
.
class
).
build
();
DateTime
dateTime
=
new
DateTime
(
1436966242231L
,
DateTimeZone
.
UTC
);
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 {
@Test
public
void
testJmsListenerContainerFactoryWithCustomSettings
()
{
load
(
EnableJmsConfiguration
.
class
,
"spring.jms.listener.autoStartup=false"
,
load
(
EnableJmsConfiguration
.
class
,
"spring.jms.listener.autoStartup=false"
,
"spring.jms.listener.acknowledgeMode=client"
,
"spring.jms.listener.concurrency=2"
,
"spring.jms.listener.maxConcurrency=10"
);
...
...
@@ -155,10 +154,11 @@ public class JmsAutoConfigurationTests {
.
getBean
(
"jmsListenerContainerFactory"
,
JmsListenerContainerFactory
.
class
);
assertEquals
(
DefaultJmsListenerContainerFactory
.
class
,
jmsListenerContainerFactory
.
getClass
());
DefaultMessageListenerContainer
listenerContainer
=
((
DefaultJmsListenerContainerFactory
)
jmsListenerContainerFactory
)
.
createListenerContainer
(
mock
(
JmsListenerEndpoint
.
class
));
DefaultMessageListenerContainer
listenerContainer
=
((
DefaultJmsListenerContainerFactory
)
jmsListenerContainerFactory
)
.
createListenerContainer
(
mock
(
JmsListenerEndpoint
.
class
));
assertEquals
(
false
,
listenerContainer
.
isAutoStartup
());
assertEquals
(
Session
.
CLIENT_ACKNOWLEDGE
,
listenerContainer
.
getSessionAcknowledgeMode
());
assertEquals
(
Session
.
CLIENT_ACKNOWLEDGE
,
listenerContainer
.
getSessionAcknowledgeMode
());
assertEquals
(
2
,
listenerContainer
.
getConcurrentConsumers
());
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 @@
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.util.Arrays
;
import
java.util.List
;
...
...
@@ -94,6 +91,9 @@ import org.springframework.web.client.RestTemplate;
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
* environmental overrides, and also backs off in the presence of other
...
...
@@ -358,9 +358,9 @@ public class OAuth2AutoConfigurationTests {
@Configuration
@Import
({
UseFreePortEmbeddedContainerConfiguration
.
class
,
SecurityAutoConfiguration
.
class
,
ServerPropertiesAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
,
OAuth2AutoConfiguration
.
class
,
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
})
SecurityAutoConfiguration
.
class
,
ServerPropertiesAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
,
OAuth2AutoConfiguration
.
class
,
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
})
protected
static
class
MinimalSecureWebApplication
{
}
...
...
@@ -396,7 +396,7 @@ public class OAuth2AutoConfigurationTests {
@EnableResourceServer
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
protected
static
class
AuthorizationAndResourceServerConfiguration
extends
TestSecurityConfiguration
{
TestSecurityConfiguration
{
}
...
...
@@ -419,7 +419,7 @@ public class OAuth2AutoConfigurationTests {
@Configuration
@EnableAuthorizationServer
protected
static
class
AuthorizationServerConfiguration
extends
TestSecurityConfiguration
{
TestSecurityConfiguration
{
}
...
...
@@ -474,7 +474,7 @@ public class OAuth2AutoConfigurationTests {
@Override
public
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
authorizeRequests
().
anyRequest
().
authenticated
().
and
().
httpBasic
().
and
()
.
csrf
().
disable
();
.
csrf
().
disable
();
}
}
...
...
@@ -482,7 +482,7 @@ public class OAuth2AutoConfigurationTests {
@Configuration
@EnableAuthorizationServer
protected
static
class
CustomAuthorizationServer
extends
AuthorizationServerConfigurerAdapter
{
AuthorizationServerConfigurerAdapter
{
@Autowired
private
AuthenticationManager
authenticationManager
;
...
...
@@ -502,9 +502,9 @@ public class OAuth2AutoConfigurationTests {
@Override
public
void
configure
(
ClientDetailsServiceConfigurer
clients
)
throws
Exception
{
clients
.
inMemory
().
withClient
(
"client"
).
secret
(
"secret"
)
.
resourceIds
(
"resource-id"
).
authorizedGrantTypes
(
"password"
)
.
authorities
(
"USER"
).
scopes
(
"read"
)
.
redirectUris
(
"http://localhost:8080"
);
.
resourceIds
(
"resource-id"
).
authorizedGrantTypes
(
"password"
)
.
authorities
(
"USER"
).
scopes
(
"read"
)
.
redirectUris
(
"http://localhost:8080"
);
}
@Override
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerIntegrationTests.java
View file @
891dd5a0
...
...
@@ -181,6 +181,7 @@ public class BasicErrorControllerIntegrationTests {
public
NoReasonExpectedException
(
String
message
)
{
super
(
message
);
}
}
}
...
...
spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
891dd5a0
...
...
@@ -1476,7 +1476,6 @@ respectively.
[[howto-use-exposing-spring-data-repositories-rest-endpoint]]
=== Expose Spring Data repositories as REST endpoint
Spring Data REST can expose the `Repository` implementations as REST endpoints for you as
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:
}
----
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
`ConnectionSettings` example:
...
...
spring-boot-samples/spring-boot-sample-property-validation/pom.xml
View file @
891dd5a0
...
...
@@ -23,13 +23,11 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-configuration-processor
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<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 {
private
Integer
port
=
8080
;
public
String
getHost
()
{
return
host
;
return
this
.
host
;
}
public
void
setHost
(
String
host
)
{
...
...
@@ -42,10 +42,11 @@ public class SampleProperties {
}
public
Integer
getPort
()
{
return
port
;
return
this
.
port
;
}
public
void
setPort
(
Integer
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 {
public
void
validate
(
Object
o
,
Errors
errors
)
{
ValidationUtils
.
rejectIfEmpty
(
errors
,
"host"
,
"host.empty"
);
ValidationUtils
.
rejectIfEmpty
(
errors
,
"port"
,
"port.empty"
);
SampleProperties
properties
=
(
SampleProperties
)
o
;
if
(
properties
.
getHost
()
!=
null
&&
!
pattern
.
matcher
(
properties
.
getHost
()).
matches
())
{
if
(
properties
.
getHost
()
!=
null
&&
!
this
.
pattern
.
matcher
(
properties
.
getHost
()).
matches
())
{
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 {
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
SpringApplicationBuilder
(
SamplePropertyValidationApplication
.
class
)
.
profiles
(
"app"
).
run
(
args
);
new
SpringApplicationBuilder
(
SamplePropertyValidationApplication
.
class
)
.
profiles
(
"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;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.boot.autoconfigure.web.ServerProperties
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
...
...
@@ -43,16 +42,15 @@ public class SamplePropertyValidationApplicationTests {
@After
public
void
closeContext
()
{
context
.
close
();
this
.
context
.
close
();
}
@Test
public
void
bindValidProperties
()
{
this
.
context
.
register
(
SamplePropertyValidationApplication
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"sample.
host:192.168.0.1"
,
"sample.
port:9090"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"sample.host:192.168.0.1"
,
"sample.port:9090"
);
this
.
context
.
refresh
();
SampleProperties
properties
=
this
.
context
.
getBean
(
SampleProperties
.
class
);
assertEquals
(
"192.168.0.1"
,
properties
.
getHost
());
assertEquals
(
Integer
.
valueOf
(
9090
),
properties
.
getPort
());
...
...
@@ -61,32 +59,29 @@ public class SamplePropertyValidationApplicationTests {
@Test
public
void
bindInvalidHost
()
{
this
.
context
.
register
(
SamplePropertyValidationApplication
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"sample.host:xxxxxx"
,
"sample.port:9090"
);
thrown
.
expect
(
BeanCreationException
.
class
);
thrown
.
expectMessage
(
"xxxxxx"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"sample.host:xxxxxx"
,
"sample.port:9090"
);
this
.
thrown
.
expect
(
BeanCreationException
.
class
);
this
.
thrown
.
expectMessage
(
"xxxxxx"
);
this
.
context
.
refresh
();
}
@Test
public
void
bindNullHost
()
{
this
.
context
.
register
(
SamplePropertyValidationApplication
.
class
);
thrown
.
expect
(
BeanCreationException
.
class
);
thrown
.
expectMessage
(
"null"
);
thrown
.
expectMessage
(
"host"
);
this
.
thrown
.
expect
(
BeanCreationException
.
class
);
this
.
thrown
.
expectMessage
(
"null"
);
this
.
thrown
.
expectMessage
(
"host"
);
this
.
context
.
refresh
();
}
@Test
public
void
validatorOnlyCalledOnSupportedClass
()
{
this
.
context
.
register
(
SamplePropertyValidationApplication
.
class
);
this
.
context
.
register
(
ServerProperties
.
class
);
// our validator will not apply
here
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"sample.
host:192.168.0.1"
,
"sample.
port:9090"
);
this
.
context
.
register
(
ServerProperties
.
class
);
// our validator will not apply
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"sample.host:192.168.0.1"
,
"sample.port:9090"
);
this
.
context
.
refresh
();
SampleProperties
properties
=
this
.
context
.
getBean
(
SampleProperties
.
class
);
assertEquals
(
"192.168.0.1"
,
properties
.
getHost
());
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 {
if
(
this
.
rootClassLoader
==
null
)
{
return
findResources
(
name
);
}
final
Enumeration
<
URL
>
rootResources
=
this
.
rootClassLoader
.
getResources
(
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
();
}
};
return
new
ResourceEnumeration
(
this
.
rootClassLoader
.
getResources
(
name
),
findResources
(
name
));
}
/**
...
...
@@ -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 {
bind
(
target
,
"nested.foo: bar.key\n"
+
"nested[bar.key].spam: bucket\n"
+
"nested[bar.key].value: 123\nnested[bar.key].foo: crap"
);
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
);
assertEquals
(
3
,
nestedMap
.
size
());
assertEquals
(
"123"
,
nestedMap
.
get
(
"value"
));
assertEquals
(
"123"
,
nestedMap
.
get
(
"value"
));
assertEquals
(
"bar.key"
,
target
.
getNested
().
get
(
"foo"
));
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