Skip to content

Commit 607ed86

Browse files
committed
Merge branch '3.0.x' into 3.1.x
2 parents cf4fcc5 + dccf378 commit 607ed86

File tree

10 files changed

+28
-34
lines changed

10 files changed

+28
-34
lines changed

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ class ReactiveCloudFoundrySecurityService {
5353

5454
private final String cloudControllerUrl;
5555

56-
private Mono<String> uaaUrl;
57-
5856
ReactiveCloudFoundrySecurityService(WebClient.Builder webClientBuilder, String cloudControllerUrl,
5957
boolean skipSslValidation) {
6058
Assert.notNull(webClientBuilder, "WebClient must not be null");
@@ -149,15 +147,14 @@ private Map<String, String> extractTokenKeys(Map<String, Object> response) {
149147
* @return the UAA url Mono
150148
*/
151149
Mono<String> getUaaUrl() {
152-
this.uaaUrl = this.webClient.get()
150+
return this.webClient.get()
153151
.uri(this.cloudControllerUrl + "/info")
154152
.retrieve()
155153
.bodyToMono(Map.class)
156154
.map((response) -> (String) response.get("token_endpoint"))
157155
.cache()
158156
.onErrorMap((ex) -> new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
159157
"Unable to fetch token keys from UAA."));
160-
return this.uaaUrl;
161158
}
162159

163160
}

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
import java.security.spec.InvalidKeySpecException;
2525
import java.security.spec.X509EncodedKeySpec;
2626
import java.util.Base64;
27+
import java.util.Collections;
2728
import java.util.Map;
28-
import java.util.concurrent.ConcurrentHashMap;
29-
import java.util.concurrent.ConcurrentMap;
3029
import java.util.concurrent.TimeUnit;
3130

3231
import reactor.core.publisher.Mono;
@@ -44,7 +43,7 @@ class ReactiveTokenValidator {
4443

4544
private final ReactiveCloudFoundrySecurityService securityService;
4645

47-
private volatile ConcurrentMap<String, String> cachedTokenKeys = new ConcurrentHashMap<>();
46+
private volatile Map<String, String> cachedTokenKeys = Collections.emptyMap();
4847

4948
ReactiveTokenValidator(ReactiveCloudFoundrySecurityService securityService) {
5049
this.securityService = securityService;
@@ -92,7 +91,7 @@ private Mono<String> getTokenKey(Token token) {
9291
}
9392

9493
private void cacheTokenKeys(Map<String, String> tokenKeys) {
95-
this.cachedTokenKeys = new ConcurrentHashMap<>(tokenKeys);
94+
this.cachedTokenKeys = Map.copyOf(tokenKeys);
9695
}
9796

9897
private boolean hasValidSignature(Token token, String key) {

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
6868
import org.springframework.security.web.util.matcher.OrRequestMatcher;
6969
import org.springframework.security.web.util.matcher.RequestMatcher;
70-
import org.springframework.util.CollectionUtils;
7170
import org.springframework.web.cors.CorsConfiguration;
7271
import org.springframework.web.servlet.DispatcherServlet;
7372

@@ -125,8 +124,8 @@ public CloudFoundryWebEndpointServletHandlerMapping cloudFoundryWebEndpointServl
125124
allEndpoints.addAll(webEndpoints);
126125
allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
127126
allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
128-
return new CloudFoundryWebEndpointServletHandlerMapping(new EndpointMapping("/cloudfoundryapplication"),
129-
webEndpoints, endpointMediaTypes, getCorsConfiguration(), securityInterceptor, allEndpoints);
127+
return new CloudFoundryWebEndpointServletHandlerMapping(new EndpointMapping(BASE_PATH), webEndpoints,
128+
endpointMediaTypes, getCorsConfiguration(), securityInterceptor, allEndpoints);
130129
}
131130

132131
private CloudFoundrySecurityInterceptor getSecurityInterceptor(RestTemplateBuilder restTemplateBuilder,
@@ -189,9 +188,7 @@ public void customize(WebSecurity web) {
189188
.forEach((path) -> requestMatchers.add(new AntPathRequestMatcher(path + "/**")));
190189
requestMatchers.add(new AntPathRequestMatcher(BASE_PATH));
191190
requestMatchers.add(new AntPathRequestMatcher(BASE_PATH + "/"));
192-
if (!CollectionUtils.isEmpty(requestMatchers)) {
193-
web.ignoring().requestMatchers(new OrRequestMatcher(requestMatchers));
194-
}
191+
web.ignoring().requestMatchers(new OrRequestMatcher(requestMatchers));
195192
}
196193

197194
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/CompositePropagationFactoryTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void requires128BitTraceId() {
6565
}
6666

6767
@Nested
68-
static class CompostePropagationTests {
68+
class CompositePropagationTests {
6969

7070
@Test
7171
void keys() {

spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsR2dbcAutoConfigurationTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -152,12 +152,12 @@ private void onEvent(R2dbcDatabaseShutdownEvent event) {
152152

153153
@Nested
154154
@ClassPathExclusions("r2dbc-pool*.jar")
155-
static class Embedded extends Common {
155+
class Embedded extends Common {
156156

157157
}
158158

159159
@Nested
160-
static class Pooled extends Common {
160+
class Pooled extends Common {
161161

162162
}
163163

spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestartApplicationListenerTests.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.springframework.test.util.ReflectionTestUtils;
3737

3838
import static org.assertj.core.api.Assertions.assertThat;
39-
import static org.hamcrest.Matchers.nullValue;
4039
import static org.mockito.Mockito.mock;
4140

4241
/**
@@ -117,7 +116,7 @@ private void testInitialize(boolean failed, RestartApplicationListener listener)
117116
SpringApplication application = new SpringApplication();
118117
ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
119118
listener.onApplicationEvent(new ApplicationStartingEvent(bootstrapContext, application, ARGS));
120-
assertThat(Restarter.getInstance()).isNotEqualTo(nullValue());
119+
assertThat(Restarter.getInstance()).isNotNull();
121120
assertThat(Restarter.getInstance().isFinished()).isFalse();
122121
listener.onApplicationEvent(new ApplicationPreparedEvent(application, ARGS, context));
123122
if (failed) {

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/SpringBootMockMvcBuilderCustomizer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static DeferredLinesWriter get(ApplicationContext applicationContext) {
253253
}
254254

255255
void clear() {
256-
this.lines.get().clear();
256+
this.lines.remove();
257257
}
258258

259259
}

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/json/JsonStream.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -64,13 +64,14 @@ public void get(InputStream content, Consumer<ObjectNode> consumer) throws IOExc
6464
*/
6565
public <T> void get(InputStream content, Class<T> type, Consumer<T> consumer) throws IOException {
6666
JsonFactory jsonFactory = this.objectMapper.getFactory();
67-
JsonParser parser = jsonFactory.createParser(content);
68-
while (!parser.isClosed()) {
69-
JsonToken token = parser.nextToken();
70-
if (token != null && token != JsonToken.END_OBJECT) {
71-
T node = read(parser, type);
72-
if (node != null) {
73-
consumer.accept(node);
67+
try (JsonParser parser = jsonFactory.createParser(content)) {
68+
while (!parser.isClosed()) {
69+
JsonToken token = parser.nextToken();
70+
if (token != null && token != JsonToken.END_OBJECT) {
71+
T node = read(parser, type);
72+
if (node != null) {
73+
consumer.accept(node);
74+
}
7475
}
7576
}
7677
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ private Package findPackage(CharSequence source) {
265265
.getResources(ClassUtils.convertClassNameToResourcePath(source.toString()) + "/*.class");
266266
for (Resource resource : resources) {
267267
String className = StringUtils.stripFilenameExtension(resource.getFilename());
268-
load(Class.forName(source.toString() + "." + className));
268+
load(Class.forName(source + "." + className));
269269
break;
270270
}
271271
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/StandardConfigDataResource.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private boolean isSameUnderlyingResource(Resource ours, Resource other) {
106106
}
107107

108108
private boolean isSameFile(File ours, File other) {
109-
return (ours != null) && (other != null) && ours.equals(other);
109+
return (ours != null) && ours.equals(other);
110110
}
111111

112112
@Override
@@ -119,9 +119,10 @@ public int hashCode() {
119119
public String toString() {
120120
if (this.resource instanceof FileSystemResource || this.resource instanceof FileUrlResource) {
121121
try {
122-
return "file [" + this.resource.getFile().toString() + "]";
122+
return "file [" + this.resource.getFile() + "]";
123123
}
124124
catch (IOException ex) {
125+
// Ignore
125126
}
126127
}
127128
return this.resource.toString();
@@ -131,11 +132,11 @@ private File getUnderlyingFile(Resource resource) {
131132
try {
132133
if (resource instanceof ClassPathResource || resource instanceof FileSystemResource
133134
|| resource instanceof FileUrlResource) {
134-
File file = resource.getFile();
135-
return (file != null) ? file.getAbsoluteFile() : null;
135+
return resource.getFile().getAbsoluteFile();
136136
}
137137
}
138138
catch (IOException ex) {
139+
// Ignore
139140
}
140141
return null;
141142
}

0 commit comments

Comments
 (0)