Skip to content

Commit c6c139d

Browse files
committed
Merge branch '1.5.x' into 2.0.x
2 parents 3f3d1d1 + 8f1be4c commit c6c139d

File tree

2,320 files changed

+23855
-39473
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,320 files changed

+23855
-39473
lines changed

pom.xml

+1-1
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

+9-15
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

+4-5
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.
@@ -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
private final Map<String, RabbitTemplate> rabbitTemplates;
5353

54-
public RabbitHealthIndicatorAutoConfiguration(
55-
Map<String, RabbitTemplate> rabbitTemplates) {
54+
public RabbitHealthIndicatorAutoConfiguration(Map<String, RabbitTemplate> rabbitTemplates) {
5655
this.rabbitTemplates = rabbitTemplates;
5756
}
5857

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public class AuditAutoConfiguration {
4444

4545
private final AuditEventRepository auditEventRepository;
4646

47-
public AuditAutoConfiguration(
48-
ObjectProvider<AuditEventRepository> auditEventRepository) {
47+
public AuditAutoConfiguration(ObjectProvider<AuditEventRepository> auditEventRepository) {
4948
this.auditEventRepository = auditEventRepository.getIfAvailable();
5049
}
5150

@@ -56,16 +55,14 @@ public AuditListener auditListener() throws Exception {
5655
}
5756

5857
@Bean
59-
@ConditionalOnClass(
60-
name = "org.springframework.security.authentication.event.AbstractAuthenticationEvent")
58+
@ConditionalOnClass(name = "org.springframework.security.authentication.event.AbstractAuthenticationEvent")
6159
@ConditionalOnMissingBean(AbstractAuthenticationAuditListener.class)
6260
public AuthenticationAuditListener authenticationAuditListener() throws Exception {
6361
return new AuthenticationAuditListener();
6462
}
6563

6664
@Bean
67-
@ConditionalOnClass(
68-
name = "org.springframework.security.access.event.AbstractAuthorizationEvent")
65+
@ConditionalOnClass(name = "org.springframework.security.access.event.AbstractAuthorizationEvent")
6966
@ConditionalOnMissingBean(AbstractAuthorizationAuditListener.class)
7067
public AuthorizationAuditListener authorizationAuditListener() throws Exception {
7168
return new AuthorizationAuditListener();

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

+2-3
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.
@@ -43,8 +43,7 @@ public class AuditEventsEndpointAutoConfiguration {
4343
@ConditionalOnMissingBean
4444
@ConditionalOnBean(AuditEventRepository.class)
4545
@ConditionalOnEnabledEndpoint
46-
public AuditEventsEndpoint auditEventsEndpoint(
47-
AuditEventRepository auditEventRepository) {
46+
public AuditEventsEndpoint auditEventsEndpoint(AuditEventRepository auditEventRepository) {
4847
return new AuditEventsEndpoint(auditEventRepository);
4948
}
5049

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

+2-3
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.
@@ -36,8 +36,7 @@ public class BeansEndpointAutoConfiguration {
3636
@Bean
3737
@ConditionalOnMissingBean
3838
@ConditionalOnEnabledEndpoint
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/cassandra/CassandraHealthIndicatorAutoConfiguration.java

+5-7
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.
@@ -49,15 +49,13 @@
4949
@ConditionalOnBean(CassandraOperations.class)
5050
@ConditionalOnEnabledHealthIndicator("cassandra")
5151
@AutoConfigureBefore(HealthIndicatorAutoConfiguration.class)
52-
@AutoConfigureAfter({ CassandraAutoConfiguration.class,
53-
CassandraDataAutoConfiguration.class })
54-
public class CassandraHealthIndicatorAutoConfiguration extends
55-
CompositeHealthIndicatorConfiguration<CassandraHealthIndicator, CassandraOperations> {
52+
@AutoConfigureAfter({ CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class })
53+
public class CassandraHealthIndicatorAutoConfiguration
54+
extends CompositeHealthIndicatorConfiguration<CassandraHealthIndicator, CassandraOperations> {
5655

5756
private final Map<String, CassandraOperations> cassandraOperations;
5857

59-
public CassandraHealthIndicatorAutoConfiguration(
60-
Map<String, CassandraOperations> cassandraOperations) {
58+
public CassandraHealthIndicatorAutoConfiguration(Map<String, CassandraOperations> cassandraOperations) {
6159
this.cassandraOperations = cassandraOperations;
6260
}
6361

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

+2-3
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

+9-13
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.
@@ -50,35 +50,31 @@ public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer {
5050
* @param filters filters to apply
5151
*/
5252
public CloudFoundryWebEndpointDiscoverer(ApplicationContext applicationContext,
53-
ParameterValueMapper parameterValueMapper,
54-
EndpointMediaTypes endpointMediaTypes, PathMapper endpointPathMapper,
55-
Collection<OperationInvokerAdvisor> invokerAdvisors,
53+
ParameterValueMapper parameterValueMapper, EndpointMediaTypes endpointMediaTypes,
54+
PathMapper endpointPathMapper, Collection<OperationInvokerAdvisor> invokerAdvisors,
5655
Collection<EndpointFilter<ExposableWebEndpoint>> filters) {
57-
super(applicationContext, parameterValueMapper, endpointMediaTypes,
58-
endpointPathMapper, invokerAdvisors, filters);
56+
super(applicationContext, parameterValueMapper, endpointMediaTypes, endpointPathMapper, 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-
AnnotationAttributes attributes = AnnotatedElementUtils
73-
.getMergedAnnotationAttributes(extensionBean.getClass(),
74-
EndpointWebExtension.class);
70+
AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(extensionBean.getClass(),
71+
EndpointWebExtension.class);
7572
Class<?> endpoint = (attributes != null) ? attributes.getClass("endpoint") : null;
7673
return (endpoint != null && HealthEndpoint.class.isAssignableFrom(endpoint));
7774
}
7875

7976
private boolean isCloudFoundryHealthEndpointExtension(Object extensionBean) {
80-
return AnnotatedElementUtils.hasAnnotation(extensionBean.getClass(),
81-
HealthEndpointCloudFoundryExtension.class);
77+
return AnnotatedElementUtils.hasAnnotation(extensionBean.getClass(), HealthEndpointCloudFoundryExtension.class);
8278
}
8379

8480
}

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
@Target(ElementType.TYPE)
3636
@Retention(RetentionPolicy.RUNTIME)
3737
@Documented
38-
@EndpointExtension(filter = CloudFoundryEndpointFilter.class,
39-
endpoint = HealthEndpoint.class)
38+
@EndpointExtension(filter = CloudFoundryEndpointFilter.class, endpoint = HealthEndpoint.class)
4039
public @interface HealthEndpointCloudFoundryExtension {
4140

4241
}

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

+4-7
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

+2-3
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,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

+15-23
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)