Skip to content

Commit 91a7bf9

Browse files
committed
Merge branch '1.5.x'
2 parents dcf7e11 + fedd7b9 commit 91a7bf9

File tree

10 files changed

+43
-27
lines changed

10 files changed

+43
-27
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cloudfoundry/CloudFoundryHealthMvcEndpoint.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class CloudFoundryHealthMvcEndpoint extends HealthMvcEndpoint {
3838
}
3939

4040
@Override
41-
protected boolean exposeHealthDetails(HttpServletRequest request, Principal principal) {
41+
protected boolean exposeHealthDetails(HttpServletRequest request,
42+
Principal principal) {
4243
return true;
4344
}
4445

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ private boolean isCacheStale(long accessTime) {
183183
return (accessTime - this.lastAccess) >= getDelegate().getTimeToLive();
184184
}
185185

186-
protected boolean exposeHealthDetails(HttpServletRequest request, Principal principal) {
186+
protected boolean exposeHealthDetails(HttpServletRequest request,
187+
Principal principal) {
187188
if (!this.secure) {
188189
return true;
189190
}
@@ -192,7 +193,7 @@ protected boolean exposeHealthDetails(HttpServletRequest request, Principal prin
192193
if (request.isUserInRole(role)) {
193194
return true;
194195
}
195-
if (isSpringSecurityAuthentication(principal)) {
196+
if (isSpringSecurityAuthentication(principal)) {
196197
Authentication authentication = (Authentication) principal;
197198
for (GrantedAuthority authority : authentication.getAuthorities()) {
198199
String name = authority.getAuthority();
@@ -217,7 +218,7 @@ private List<String> getRoles() {
217218

218219
private boolean isSpringSecurityAuthentication(Principal principal) {
219220
return ClassUtils.isPresent("org.springframework.security.core.Authentication",
220-
null) && (principal instanceof Authentication);
221+
null) && principal instanceof Authentication;
221222
}
222223

223224
}

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/MvcEndpointSecurityInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cloudfoundry/CloudFoundryHealthMvcEndpointTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpointTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ public void rightRoleNotPresentShouldNotExposeDetails() {
167167
public void rightAuthorityPresentShouldExposeDetails() throws Exception {
168168
this.environment.getPropertySources().addLast(SECURITY_ROLES);
169169
Authentication principal = mock(Authentication.class);
170-
Set<SimpleGrantedAuthority> authorities = Collections.singleton(new SimpleGrantedAuthority("HERO"));
170+
Set<SimpleGrantedAuthority> authorities = Collections
171+
.singleton(new SimpleGrantedAuthority("HERO"));
171172
doReturn(authorities).when(principal).getAuthorities();
172173
given(this.endpoint.invoke())
173174
.willReturn(new Health.Builder().up().withDetail("foo", "bar").build());

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityHealthMvcEndpointIntegrationTests.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,15 @@ public void closeContext() {
6767
}
6868

6969
@Test
70-
public void healthWhenRightRoleNotPresentShouldExposeHealthDetails() throws Exception {
70+
public void healthWhenRightRoleNotPresentShouldExposeHealthDetails()
71+
throws Exception {
7172
this.context = new AnnotationConfigWebApplicationContext();
7273
this.context.setServletContext(new MockServletContext());
7374
this.context.register(TestConfiguration.class);
7475
this.context.refresh();
7576
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
76-
mockMvc.perform(get("/health").with(getRequestPostProcessor())).andExpect(status().isOk())
77+
mockMvc.perform(get("/health").with(getRequestPostProcessor()))
78+
.andExpect(status().isOk())
7779
.andExpect(content().string(containsString("\"status\":\"UP\"")));
7880
}
7981

@@ -93,12 +95,15 @@ public void healthDetailPresent() throws Exception {
9395

9496
private RequestPostProcessor getRequestPostProcessor() {
9597
return new RequestPostProcessor() {
98+
9699
@Override
97-
public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
100+
public MockHttpServletRequest postProcessRequest(
101+
MockHttpServletRequest request) {
98102
Principal principal = mock(Principal.class);
99103
request.setUserPrincipal(principal);
100104
return request;
101105
}
106+
102107
};
103108
}
104109

@@ -117,6 +122,7 @@ public HealthIndicator testHealthIndicator() {
117122
public Health health() {
118123
return Health.up().withDetail("hello", "world").build();
119124
}
125+
120126
};
121127
}
122128

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public class MongoProperties {
4040
*/
4141
public static final int DEFAULT_PORT = 27017;
4242

43+
/**
44+
* Default URI used when the configured URI is {@code null}.
45+
*/
4346
public static final String DEFAULT_URI = "mongodb://localhost/test";
4447

4548
/**

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -145,25 +145,21 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
145145
if (this.beanFactory == null) {
146146
return;
147147
}
148-
if (ObjectUtils.isEmpty(this.beanFactory.getBeanNamesForType(
149-
EmbeddedServletContainerCustomizerBeanPostProcessor.class, true,
150-
false))) {
151-
RootBeanDefinition beanDefinition = new RootBeanDefinition(
152-
EmbeddedServletContainerCustomizerBeanPostProcessor.class);
153-
beanDefinition.setSynthetic(true);
154-
registry.registerBeanDefinition(
155-
"embeddedServletContainerCustomizerBeanPostProcessor",
156-
beanDefinition);
148+
registerSyntheticBeanIfMissing(registry,
149+
"embeddedServletContainerCustomizerBeanPostProcessor",
150+
EmbeddedServletContainerCustomizerBeanPostProcessor.class);
151+
registerSyntheticBeanIfMissing(registry,
152+
"errorPageRegistrarBeanPostProcessor",
153+
ErrorPageRegistrarBeanPostProcessor.class);
154+
}
157155

158-
}
159-
if (ObjectUtils.isEmpty(this.beanFactory.getBeanNamesForType(
160-
ErrorPageRegistrarBeanPostProcessor.class, true, false))) {
161-
RootBeanDefinition beanDefinition = new RootBeanDefinition(
162-
ErrorPageRegistrarBeanPostProcessor.class);
156+
private void registerSyntheticBeanIfMissing(BeanDefinitionRegistry registry,
157+
String name, Class<?> beanClass) {
158+
if (ObjectUtils.isEmpty(
159+
this.beanFactory.getBeanNamesForType(beanClass, true, false))) {
160+
RootBeanDefinition beanDefinition = new RootBeanDefinition(beanClass);
163161
beanDefinition.setSynthetic(true);
164-
registry.registerBeanDefinition("errorPageRegistrarBeanPostProcessor",
165-
beanDefinition);
166-
162+
registry.registerBeanDefinition(name, beanDefinition);
167163
}
168164
}
169165

spring-boot/src/main/java/org/springframework/boot/context/embedded/EmbeddedServletContainerCustomizerBeanPostProcessor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.beans.factory.ListableBeanFactory;
2828
import org.springframework.beans.factory.config.BeanPostProcessor;
2929
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
30+
import org.springframework.util.Assert;
3031

3132
/**
3233
* {@link BeanPostProcessor} that applies all {@link EmbeddedServletContainerCustomizer}s
@@ -45,6 +46,9 @@ public class EmbeddedServletContainerCustomizerBeanPostProcessor
4546

4647
@Override
4748
public void setBeanFactory(BeanFactory beanFactory) {
49+
Assert.isInstanceOf(ListableBeanFactory.class, beanFactory,
50+
"EmbeddedServletContainerCustomizerBeanPostProcessor can only be used "
51+
+ "with a ListableBeanFactory");
4852
this.beanFactory = (ListableBeanFactory) beanFactory;
4953
}
5054

spring-boot/src/main/java/org/springframework/boot/web/servlet/ErrorPageRegistrarBeanPostProcessor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.beans.factory.ListableBeanFactory;
2828
import org.springframework.beans.factory.config.BeanPostProcessor;
2929
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
30+
import org.springframework.util.Assert;
3031

3132
/**
3233
* {@link BeanPostProcessor} that applies all {@link ErrorPageRegistrar}s from the bean
@@ -45,6 +46,9 @@ public class ErrorPageRegistrarBeanPostProcessor
4546

4647
@Override
4748
public void setBeanFactory(BeanFactory beanFactory) {
49+
Assert.isInstanceOf(ListableBeanFactory.class, beanFactory,
50+
"ErrorPageRegistrarBeanPostProcessor can only be used "
51+
+ "with a ListableBeanFactory");
4852
this.beanFactory = (ListableBeanFactory) beanFactory;
4953
}
5054

0 commit comments

Comments
 (0)