Skip to content

Commit aef92b9

Browse files
committed
Merge branch '2.1.x'
Closes gh-17079
2 parents 5b2de5c + 24925c3 commit aef92b9

File tree

2,799 files changed

+28373
-47807
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,799 files changed

+28373
-47807
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</property>
2525
</activation>
2626
<properties>
27-
<spring-javaformat.version>0.0.9</spring-javaformat.version>
27+
<spring-javaformat.version>0.0.11</spring-javaformat.version>
2828
<nohttp-checkstyle.version>0.0.1.RELEASE</nohttp-checkstyle.version>
2929
</properties>
3030
<build>

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 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.
@@ -40,15 +40,13 @@ public abstract class OnEndpointElementCondition extends SpringBootCondition {
4040

4141
private final Class<? extends Annotation> annotationType;
4242

43-
protected OnEndpointElementCondition(String prefix,
44-
Class<? extends Annotation> annotationType) {
43+
protected OnEndpointElementCondition(String prefix, Class<? extends Annotation> annotationType) {
4544
this.prefix = prefix;
4645
this.annotationType = annotationType;
4746
}
4847

4948
@Override
50-
public ConditionOutcome getMatchOutcome(ConditionContext context,
51-
AnnotatedTypeMetadata metadata) {
49+
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
5250
AnnotationAttributes annotationAttributes = AnnotationAttributes
5351
.fromMap(metadata.getAnnotationAttributes(this.annotationType.getName()));
5452
String endpointName = annotationAttributes.getString("value");
@@ -59,25 +57,21 @@ public ConditionOutcome getMatchOutcome(ConditionContext context,
5957
return getDefaultEndpointsOutcome(context);
6058
}
6159

62-
protected ConditionOutcome getEndpointOutcome(ConditionContext context,
63-
String endpointName) {
60+
protected ConditionOutcome getEndpointOutcome(ConditionContext context, String endpointName) {
6461
Environment environment = context.getEnvironment();
6562
String enabledProperty = this.prefix + endpointName + ".enabled";
6663
if (environment.containsProperty(enabledProperty)) {
6764
boolean match = environment.getProperty(enabledProperty, Boolean.class, true);
68-
return new ConditionOutcome(match,
69-
ConditionMessage.forCondition(this.annotationType).because(
70-
this.prefix + endpointName + ".enabled is " + match));
65+
return new ConditionOutcome(match, ConditionMessage.forCondition(this.annotationType)
66+
.because(this.prefix + endpointName + ".enabled is " + match));
7167
}
7268
return null;
7369
}
7470

7571
protected ConditionOutcome getDefaultEndpointsOutcome(ConditionContext context) {
76-
boolean match = Boolean.valueOf(context.getEnvironment()
77-
.getProperty(this.prefix + "defaults.enabled", "true"));
78-
return new ConditionOutcome(match,
79-
ConditionMessage.forCondition(this.annotationType).because(
80-
this.prefix + "defaults.enabled is considered " + match));
72+
boolean match = Boolean.valueOf(context.getEnvironment().getProperty(this.prefix + "defaults.enabled", "true"));
73+
return new ConditionOutcome(match, ConditionMessage.forCondition(this.annotationType)
74+
.because(this.prefix + "defaults.enabled is considered " + match));
8175
}
8276

8377
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/amqp/RabbitHealthIndicatorAutoConfiguration.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@
4646
@ConditionalOnEnabledHealthIndicator("rabbit")
4747
@AutoConfigureBefore(HealthIndicatorAutoConfiguration.class)
4848
@AutoConfigureAfter(RabbitAutoConfiguration.class)
49-
public class RabbitHealthIndicatorAutoConfiguration extends
50-
CompositeHealthIndicatorConfiguration<RabbitHealthIndicator, RabbitTemplate> {
49+
public class RabbitHealthIndicatorAutoConfiguration
50+
extends CompositeHealthIndicatorConfiguration<RabbitHealthIndicator, RabbitTemplate> {
5151

5252
@Bean
5353
@ConditionalOnMissingBean(name = "rabbitHealthIndicator")
54-
public HealthIndicator rabbitHealthIndicator(
55-
Map<String, RabbitTemplate> rabbitTemplates) {
54+
public HealthIndicator rabbitHealthIndicator(Map<String, RabbitTemplate> rabbitTemplates) {
5655
return createHealthIndicator(rabbitTemplates);
5756
}
5857

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditAutoConfiguration.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141
*/
4242
@Configuration(proxyBeanMethods = false)
4343
@ConditionalOnBean(AuditEventRepository.class)
44-
@ConditionalOnProperty(prefix = "management.auditevents", name = "enabled",
45-
matchIfMissing = true)
44+
@ConditionalOnProperty(prefix = "management.auditevents", name = "enabled", matchIfMissing = true)
4645
public class AuditAutoConfiguration {
4746

4847
@Bean
@@ -52,16 +51,14 @@ public AuditListener auditListener(AuditEventRepository auditEventRepository) {
5251
}
5352

5453
@Bean
55-
@ConditionalOnClass(
56-
name = "org.springframework.security.authentication.event.AbstractAuthenticationEvent")
54+
@ConditionalOnClass(name = "org.springframework.security.authentication.event.AbstractAuthenticationEvent")
5755
@ConditionalOnMissingBean(AbstractAuthenticationAuditListener.class)
5856
public AuthenticationAuditListener authenticationAuditListener() throws Exception {
5957
return new AuthenticationAuditListener();
6058
}
6159

6260
@Bean
63-
@ConditionalOnClass(
64-
name = "org.springframework.security.access.event.AbstractAuthorizationEvent")
61+
@ConditionalOnClass(name = "org.springframework.security.access.event.AbstractAuthorizationEvent")
6562
@ConditionalOnMissingBean(AbstractAuthorizationAuditListener.class)
6663
public AuthorizationAuditListener authorizationAuditListener() throws Exception {
6764
return new AuthorizationAuditListener();

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditEventsEndpointAutoConfiguration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ public class AuditEventsEndpointAutoConfiguration {
4242
@Bean
4343
@ConditionalOnMissingBean
4444
@ConditionalOnBean(AuditEventRepository.class)
45-
public AuditEventsEndpoint auditEventsEndpoint(
46-
AuditEventRepository auditEventRepository) {
45+
public AuditEventsEndpoint auditEventsEndpoint(AuditEventRepository auditEventRepository) {
4746
return new AuditEventsEndpoint(auditEventRepository);
4847
}
4948

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/beans/BeansEndpointAutoConfiguration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ public class BeansEndpointAutoConfiguration {
3636

3737
@Bean
3838
@ConditionalOnMissingBean
39-
public BeansEndpoint beansEndpoint(
40-
ConfigurableApplicationContext applicationContext) {
39+
public BeansEndpoint beansEndpoint(ConfigurableApplicationContext applicationContext) {
4140
return new BeansEndpoint(applicationContext);
4241
}
4342

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cache/CachesEndpointAutoConfiguration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public CachesEndpoint cachesEndpoint(Map<String, CacheManager> cacheManagers) {
5353
@Bean
5454
@ConditionalOnMissingBean
5555
@ConditionalOnBean(CachesEndpoint.class)
56-
public CachesEndpointWebExtension cachesEndpointWebExtension(
57-
CachesEndpoint cachesEndpoint) {
56+
public CachesEndpointWebExtension cachesEndpointWebExtension(CachesEndpoint cachesEndpoint) {
5857
return new CachesEndpointWebExtension(cachesEndpoint);
5958
}
6059

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cassandra/CassandraHealthIndicatorAutoConfiguration.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,14 @@
5050
@ConditionalOnBean(CassandraOperations.class)
5151
@ConditionalOnEnabledHealthIndicator("cassandra")
5252
@AutoConfigureBefore(HealthIndicatorAutoConfiguration.class)
53-
@AutoConfigureAfter({ CassandraAutoConfiguration.class,
54-
CassandraDataAutoConfiguration.class,
53+
@AutoConfigureAfter({ CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class,
5554
CassandraReactiveHealthIndicatorAutoConfiguration.class })
56-
public class CassandraHealthIndicatorAutoConfiguration extends
57-
CompositeHealthIndicatorConfiguration<CassandraHealthIndicator, CassandraOperations> {
55+
public class CassandraHealthIndicatorAutoConfiguration
56+
extends CompositeHealthIndicatorConfiguration<CassandraHealthIndicator, CassandraOperations> {
5857

5958
@Bean
6059
@ConditionalOnMissingBean(name = "cassandraHealthIndicator")
61-
public HealthIndicator cassandraHealthIndicator(
62-
Map<String, CassandraOperations> cassandraOperations) {
60+
public HealthIndicator cassandraHealthIndicator(Map<String, CassandraOperations> cassandraOperations) {
6361
return createHealthIndicator(cassandraOperations);
6462
}
6563

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryAuthorizationException.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 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.
@@ -32,8 +32,7 @@ public CloudFoundryAuthorizationException(Reason reason, String message) {
3232
this(reason, message, null);
3333
}
3434

35-
public CloudFoundryAuthorizationException(Reason reason, String message,
36-
Throwable cause) {
35+
public CloudFoundryAuthorizationException(Reason reason, String message, Throwable cause) {
3736
super(message, cause);
3837
this.reason = reason;
3938
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,29 @@ public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer {
5050
* @param filters filters to apply
5151
*/
5252
public CloudFoundryWebEndpointDiscoverer(ApplicationContext applicationContext,
53-
ParameterValueMapper parameterValueMapper,
54-
EndpointMediaTypes endpointMediaTypes, List<PathMapper> endpointPathMappers,
55-
Collection<OperationInvokerAdvisor> invokerAdvisors,
53+
ParameterValueMapper parameterValueMapper, EndpointMediaTypes endpointMediaTypes,
54+
List<PathMapper> endpointPathMappers, Collection<OperationInvokerAdvisor> invokerAdvisors,
5655
Collection<EndpointFilter<ExposableWebEndpoint>> filters) {
57-
super(applicationContext, parameterValueMapper, endpointMediaTypes,
58-
endpointPathMappers, invokerAdvisors, filters);
56+
super(applicationContext, parameterValueMapper, endpointMediaTypes, endpointPathMappers, invokerAdvisors,
57+
filters);
5958
}
6059

6160
@Override
6261
protected boolean isExtensionExposed(Object extensionBean) {
63-
if (isHealthEndpointExtension(extensionBean)
64-
&& !isCloudFoundryHealthEndpointExtension(extensionBean)) {
62+
if (isHealthEndpointExtension(extensionBean) && !isCloudFoundryHealthEndpointExtension(extensionBean)) {
6563
// Filter regular health endpoint extensions so a CF version can replace them
6664
return false;
6765
}
6866
return true;
6967
}
7068

7169
private boolean isHealthEndpointExtension(Object extensionBean) {
72-
return MergedAnnotations.from(extensionBean.getClass())
73-
.get(EndpointWebExtension.class).getValue("endpoint", Class.class)
74-
.map(HealthEndpoint.class::isAssignableFrom).orElse(false);
70+
return MergedAnnotations.from(extensionBean.getClass()).get(EndpointWebExtension.class)
71+
.getValue("endpoint", Class.class).map(HealthEndpoint.class::isAssignableFrom).orElse(false);
7572
}
7673

7774
private boolean isCloudFoundryHealthEndpointExtension(Object extensionBean) {
78-
return MergedAnnotations.from(extensionBean.getClass())
79-
.isPresent(EndpointCloudFoundryExtension.class);
75+
return MergedAnnotations.from(extensionBean.getClass()).isPresent(EndpointCloudFoundryExtension.class);
8076
}
8177

8278
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/Token.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 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.
@@ -61,12 +61,10 @@ public Token(String encoded) {
6161
private Map<String, Object> parseJson(String base64) {
6262
try {
6363
byte[] bytes = Base64Utils.decodeFromUrlSafeString(base64);
64-
return JsonParserFactory.getJsonParser()
65-
.parseMap(new String(bytes, StandardCharsets.UTF_8));
64+
return JsonParserFactory.getJsonParser().parseMap(new String(bytes, StandardCharsets.UTF_8));
6665
}
6766
catch (RuntimeException ex) {
68-
throw new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN,
69-
"Token could not be parsed", ex);
67+
throw new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN, "Token could not be parsed", ex);
7068
}
7169
}
7270

@@ -103,8 +101,7 @@ public String getKeyId() {
103101
private <T> T getRequired(Map<String, Object> map, String key, Class<T> type) {
104102
Object value = map.get(key);
105103
if (value == null) {
106-
throw new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN,
107-
"Unable to get value from key " + key);
104+
throw new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN, "Unable to get value from key " + key);
108105
}
109106
if (!type.isInstance(value)) {
110107
throw new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN,

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundryReactiveHealthEndpointWebExtension.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ public class CloudFoundryReactiveHealthEndpointWebExtension {
3939

4040
private final ReactiveHealthEndpointWebExtension delegate;
4141

42-
public CloudFoundryReactiveHealthEndpointWebExtension(
43-
ReactiveHealthEndpointWebExtension delegate) {
42+
public CloudFoundryReactiveHealthEndpointWebExtension(ReactiveHealthEndpointWebExtension delegate) {
4443
this.delegate = delegate;
4544
}
4645

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundrySecurityInterceptor.java

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 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.
@@ -39,21 +39,18 @@
3939
*/
4040
class CloudFoundrySecurityInterceptor {
4141

42-
private static final Log logger = LogFactory
43-
.getLog(CloudFoundrySecurityInterceptor.class);
42+
private static final Log logger = LogFactory.getLog(CloudFoundrySecurityInterceptor.class);
4443

4544
private final ReactiveTokenValidator tokenValidator;
4645

4746
private final ReactiveCloudFoundrySecurityService cloudFoundrySecurityService;
4847

4948
private final String applicationId;
5049

51-
private static final Mono<SecurityResponse> SUCCESS = Mono
52-
.just(SecurityResponse.success());
50+
private static final Mono<SecurityResponse> SUCCESS = Mono.just(SecurityResponse.success());
5351

5452
CloudFoundrySecurityInterceptor(ReactiveTokenValidator tokenValidator,
55-
ReactiveCloudFoundrySecurityService cloudFoundrySecurityService,
56-
String applicationId) {
53+
ReactiveCloudFoundrySecurityService cloudFoundrySecurityService, String applicationId) {
5754
this.tokenValidator = tokenValidator;
5855
this.cloudFoundrySecurityService = cloudFoundrySecurityService;
5956
this.applicationId = applicationId;
@@ -65,15 +62,14 @@ Mono<SecurityResponse> preHandle(ServerWebExchange exchange, String id) {
6562
return SUCCESS;
6663
}
6764
if (!StringUtils.hasText(this.applicationId)) {
68-
return Mono.error(new CloudFoundryAuthorizationException(
69-
Reason.SERVICE_UNAVAILABLE, "Application id is not available"));
65+
return Mono.error(new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
66+
"Application id is not available"));
7067
}
7168
if (this.cloudFoundrySecurityService == null) {
72-
return Mono.error(new CloudFoundryAuthorizationException(
73-
Reason.SERVICE_UNAVAILABLE, "Cloud controller URL is not available"));
69+
return Mono.error(new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
70+
"Cloud controller URL is not available"));
7471
}
75-
return check(exchange, id).then(SUCCESS).doOnError(this::logError)
76-
.onErrorResume(this::getErrorResponse);
72+
return check(exchange, id).then(SUCCESS).doOnError(this::logError).onErrorResume(this::getErrorResponse);
7773
}
7874

7975
private void logError(Throwable ex) {
@@ -84,13 +80,11 @@ private Mono<Void> check(ServerWebExchange exchange, String id) {
8480
try {
8581
Token token = getToken(exchange.getRequest());
8682
return this.tokenValidator.validate(token)
87-
.then(this.cloudFoundrySecurityService
88-
.getAccessLevel(token.toString(), this.applicationId))
83+
.then(this.cloudFoundrySecurityService.getAccessLevel(token.toString(), this.applicationId))
8984
.filter((accessLevel) -> accessLevel.isAccessAllowed(id))
90-
.switchIfEmpty(Mono.error(new CloudFoundryAuthorizationException(
91-
Reason.ACCESS_DENIED, "Access denied")))
92-
.doOnSuccess((accessLevel) -> exchange.getAttributes()
93-
.put("cloudFoundryAccessLevel", accessLevel))
85+
.switchIfEmpty(
86+
Mono.error(new CloudFoundryAuthorizationException(Reason.ACCESS_DENIED, "Access denied")))
87+
.doOnSuccess((accessLevel) -> exchange.getAttributes().put("cloudFoundryAccessLevel", accessLevel))
9488
.then();
9589
}
9690
catch (CloudFoundryAuthorizationException ex) {
@@ -104,15 +98,13 @@ private Mono<SecurityResponse> getErrorResponse(Throwable throwable) {
10498
return Mono.just(new SecurityResponse(cfException.getStatusCode(),
10599
"{\"security_error\":\"" + cfException.getMessage() + "\"}"));
106100
}
107-
return Mono.just(new SecurityResponse(HttpStatus.INTERNAL_SERVER_ERROR,
108-
throwable.getMessage()));
101+
return Mono.just(new SecurityResponse(HttpStatus.INTERNAL_SERVER_ERROR, throwable.getMessage()));
109102
}
110103

111104
private Token getToken(ServerHttpRequest request) {
112105
String authorization = request.getHeaders().getFirst("Authorization");
113106
String bearerPrefix = "bearer ";
114-
if (authorization == null
115-
|| !authorization.toLowerCase(Locale.ENGLISH).startsWith(bearerPrefix)) {
107+
if (authorization == null || !authorization.toLowerCase(Locale.ENGLISH).startsWith(bearerPrefix)) {
116108
throw new CloudFoundryAuthorizationException(Reason.MISSING_AUTHORIZATION,
117109
"Authorization header is missing or invalid");
118110
}

0 commit comments

Comments
 (0)