Skip to content

Commit 0d6ea79

Browse files
committed
Start building against Spring Framework 5.3.0 snapshots
See gh-21929
1 parent a0946c8 commit 0d6ea79

File tree

13 files changed

+59
-61
lines changed

13 files changed

+59
-61
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,9 @@
5959
import org.springframework.web.servlet.HandlerMapping;
6060
import org.springframework.web.servlet.handler.MatchableHandlerMapping;
6161
import org.springframework.web.servlet.handler.RequestMatchResult;
62-
import org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition;
63-
import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
64-
import org.springframework.web.servlet.mvc.condition.ProducesRequestCondition;
65-
import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition;
6662
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
6763
import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
64+
import org.springframework.web.util.UrlPathHelper;
6865

6966
/**
7067
* A custom {@link HandlerMapping} that makes {@link ExposableWebEndpoint web endpoints}
@@ -161,7 +158,6 @@ public RequestMatchResult match(HttpServletRequest request, String pattern) {
161158
@SuppressWarnings("deprecation")
162159
private static RequestMappingInfo.BuilderConfiguration getBuilderConfig() {
163160
RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration();
164-
config.setUrlPathHelper(null);
165161
config.setPathMatcher(null);
166162
config.setSuffixPatternMatch(false);
167163
config.setTrailingSlashMatch(true);
@@ -195,34 +191,21 @@ protected ServletWebOperation wrapServletWebOperation(ExposableWebEndpoint endpo
195191
}
196192

197193
private RequestMappingInfo createRequestMappingInfo(WebOperationRequestPredicate predicate, String path) {
198-
PatternsRequestCondition patterns = patternsRequestConditionForPattern(path);
199-
RequestMethodsRequestCondition methods = new RequestMethodsRequestCondition(
200-
RequestMethod.valueOf(predicate.getHttpMethod().name()));
201-
ConsumesRequestCondition consumes = new ConsumesRequestCondition(
202-
StringUtils.toStringArray(predicate.getConsumes()));
203-
ProducesRequestCondition produces = new ProducesRequestCondition(
204-
StringUtils.toStringArray(predicate.getProduces()));
205-
return new RequestMappingInfo(null, patterns, methods, null, null, consumes, produces, null);
194+
return RequestMappingInfo.paths(this.endpointMapping.createSubPath(path))
195+
.methods(RequestMethod.valueOf(predicate.getHttpMethod().name()))
196+
.consumes(predicate.getConsumes().toArray(new String[0]))
197+
.produces(predicate.getProduces().toArray(new String[0])).build();
206198
}
207199

208200
private void registerLinksMapping() {
209-
PatternsRequestCondition patterns = patternsRequestConditionForPattern("");
210-
RequestMethodsRequestCondition methods = new RequestMethodsRequestCondition(RequestMethod.GET);
211-
ProducesRequestCondition produces = new ProducesRequestCondition(this.endpointMediaTypes.getProduced()
212-
.toArray(StringUtils.toStringArray(this.endpointMediaTypes.getProduced())));
213-
RequestMappingInfo mapping = new RequestMappingInfo(patterns, methods, null, null, null, produces, null);
201+
RequestMappingInfo mapping = RequestMappingInfo.paths(this.endpointMapping.createSubPath(""))
202+
.methods(RequestMethod.GET).produces(this.endpointMediaTypes.getProduced().toArray(new String[0]))
203+
.options(builderConfig).build();
214204
LinksHandler linksHandler = getLinksHandler();
215205
registerMapping(mapping, linksHandler, ReflectionUtils.findMethod(linksHandler.getClass(), "links",
216206
HttpServletRequest.class, HttpServletResponse.class));
217207
}
218208

219-
@SuppressWarnings("deprecation")
220-
private PatternsRequestCondition patternsRequestConditionForPattern(String path) {
221-
String[] patterns = new String[] { this.endpointMapping.createSubPath(path) };
222-
return new PatternsRequestCondition(patterns, builderConfig.getUrlPathHelper(), builderConfig.getPathMatcher(),
223-
builderConfig.useSuffixPatternMatch(), builderConfig.useTrailingSlashMatch());
224-
}
225-
226209
@Override
227210
protected boolean hasCorsConfigurationSource(Object handler) {
228211
return this.corsConfiguration != null;
@@ -332,7 +315,7 @@ private Map<String, Object> getArguments(HttpServletRequest request, Map<String,
332315
}
333316

334317
private Object getRemainingPathSegments(HttpServletRequest request) {
335-
String[] pathTokens = tokenize(request, HandlerMapping.LOOKUP_PATH, true);
318+
String[] pathTokens = tokenize(request, UrlPathHelper.PATH_ATTRIBUTE, true);
336319
String[] patternTokens = tokenize(request, HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, false);
337320
int numberOfRemainingPathSegments = pathTokens.length - patternTokens.length + 1;
338321
Assert.state(numberOfRemainingPathSegments >= 0, "Unable to extract remaining path segments");

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/SkipPathExtensionContentNegotiation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
import javax.servlet.http.HttpServletRequest;
2020
import javax.servlet.http.HttpServletResponse;
2121

22-
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
22+
import org.springframework.web.servlet.HandlerInterceptor;
2323

2424
/**
25-
* {@link HandlerInterceptorAdapter} to ensure that
25+
* {@link HandlerInterceptor} to ensure that
2626
* {@link org.springframework.web.accept.PathExtensionContentNegotiationStrategy} is
2727
* skipped for web endpoints.
2828
*
2929
* @author Phillip Webb
3030
*/
31-
final class SkipPathExtensionContentNegotiation extends HandlerInterceptorAdapter {
31+
final class SkipPathExtensionContentNegotiation implements HandlerInterceptor {
3232

3333
@SuppressWarnings("deprecation")
3434
private static final String SKIP_ATTRIBUTE = org.springframework.web.accept.PathExtensionContentNegotiationStrategy.class

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 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.
@@ -121,6 +121,13 @@ private RequestMatchResult getMatchResult(String servletPath) {
121121
context.register(TestEndpointConfiguration.class);
122122
context.refresh();
123123
WebMvcEndpointHandlerMapping bean = context.getBean(WebMvcEndpointHandlerMapping.class);
124+
try {
125+
// Trigger initLookupPath
126+
bean.getHandler(request);
127+
}
128+
catch (Exception ex) {
129+
throw new RuntimeException(ex);
130+
}
124131
return bean.match(request, "/spring");
125132
}
126133

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 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.
@@ -128,7 +128,8 @@ private List<ServerWebExchangeMatcher> getDelegateMatchers() {
128128
}
129129

130130
private Stream<String> getPatterns() {
131-
return this.locations.stream().flatMap(StaticResourceLocation::getPatterns);
131+
return this.locations.stream().flatMap(StaticResourceLocation::getPatterns)
132+
.map((pattern) -> pattern.replace("/**/", "/*/"));
132133
}
133134

134135
@Override

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -284,18 +284,6 @@ public ContentNegotiatingViewResolver viewResolver(BeanFactory beanFactory) {
284284
return resolver;
285285
}
286286

287-
@Bean
288-
@ConditionalOnMissingBean
289-
@ConditionalOnProperty(prefix = "spring.mvc", name = "locale")
290-
public LocaleResolver localeResolver() {
291-
if (this.mvcProperties.getLocaleResolver() == WebMvcProperties.LocaleResolver.FIXED) {
292-
return new FixedLocaleResolver(this.mvcProperties.getLocale());
293-
}
294-
AcceptHeaderLocaleResolver localeResolver = new AcceptHeaderLocaleResolver();
295-
localeResolver.setDefaultLocale(this.mvcProperties.getLocale());
296-
return localeResolver;
297-
}
298-
299287
@Override
300288
public MessageCodesResolver getMessageCodesResolver() {
301289
if (this.mvcProperties.getMessageCodesResolverFormat() != null) {
@@ -420,6 +408,19 @@ public WelcomePageHandlerMapping welcomePageHandlerMapping(ApplicationContext ap
420408
return welcomePageHandlerMapping;
421409
}
422410

411+
@Override
412+
@Bean
413+
@ConditionalOnMissingBean
414+
@ConditionalOnProperty(prefix = "spring.mvc", name = "locale", matchIfMissing = true)
415+
public LocaleResolver localeResolver() {
416+
if (this.mvcProperties.getLocaleResolver() == WebMvcProperties.LocaleResolver.FIXED) {
417+
return new FixedLocaleResolver(this.mvcProperties.getLocale());
418+
}
419+
AcceptHeaderLocaleResolver localeResolver = new AcceptHeaderLocaleResolver();
420+
localeResolver.setDefaultLocale(this.mvcProperties.getLocale());
421+
return localeResolver;
422+
}
423+
423424
private Optional<Resource> getWelcomePage() {
424425
String[] locations = getResourceLocations(this.resourceProperties.getStaticLocations());
425426
return Arrays.stream(locations).map(this::getIndexHtml).filter(this::isReadable).findFirst();

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.boot.web.reactive.function.client.WebClientCustomizer;
2929
import org.springframework.context.annotation.Bean;
3030
import org.springframework.context.annotation.Configuration;
31+
import org.springframework.http.HttpHeaders;
3132
import org.springframework.http.HttpMethod;
3233
import org.springframework.http.client.reactive.ClientHttpConnector;
3334
import org.springframework.http.client.reactive.ClientHttpResponse;
@@ -87,6 +88,7 @@ void webClientShouldApplyCustomizers() {
8788
void shouldGetPrototypeScopedBean() {
8889
this.contextRunner.withUserConfiguration(WebClientCustomizerConfig.class).run((context) -> {
8990
ClientHttpResponse response = mock(ClientHttpResponse.class);
91+
given(response.getHeaders()).willReturn(new HttpHeaders());
9092
ClientHttpConnector firstConnector = mock(ClientHttpConnector.class);
9193
given(firstConnector.connect(any(), any(), any())).willReturn(Mono.just(response));
9294
WebClient.Builder firstBuilder = context.getBean(WebClient.Builder.class);

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,12 @@ void resourceHandlerChainCustomized() {
277277
}
278278

279279
@Test
280-
void noLocaleResolver() {
281-
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean(LocaleResolver.class));
280+
void defaultLocaleResolver() {
281+
this.contextRunner.run((context) -> {
282+
assertThat(context).hasSingleBean(LocaleResolver.class);
283+
LocaleResolver localeResolver = context.getBean(LocaleResolver.class);
284+
assertThat(((AcceptHeaderLocaleResolver) localeResolver).getDefaultLocale()).isNull();
285+
});
282286
}
283287

284288
@Test

spring-boot-project/spring-boot-dependencies/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ bom {
16791679
]
16801680
}
16811681
}
1682-
library("Spring Framework", "5.2.6.RELEASE") {
1682+
library("Spring Framework", "5.3.0-SNAPSHOT") {
16831683
group("org.springframework") {
16841684
imports = [
16851685
"spring-framework-bom"

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 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.
@@ -28,7 +28,7 @@
2828
import org.springframework.beans.BeansException;
2929
import org.springframework.beans.factory.FactoryBean;
3030
import org.springframework.beans.factory.config.BeanPostProcessor;
31-
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
31+
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
3232
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
3333
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
3434
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -163,7 +163,7 @@ public Class<?> getObjectType() {
163163
/**
164164
* {@link BeanPostProcessor} used to initialize JSON testers.
165165
*/
166-
static class JsonMarshalTestersBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter {
166+
static class JsonMarshalTestersBeanPostProcessor implements InstantiationAwareBeanPostProcessor {
167167

168168
@Override
169169
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleRepository.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 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.
@@ -48,8 +48,7 @@ public void save(ExampleEntity entity) {
4848
}
4949

5050
public ExampleEntity findById(int id) {
51-
return this.jdbcTemplate.queryForObject("select id, name from example where id =?", new Object[] { id },
52-
ROW_MAPPER);
51+
return this.jdbcTemplate.queryForObject("select id, name from example where id =?", ROW_MAPPER, id);
5352
}
5453

5554
public Collection<ExampleEntity> findAll() {

0 commit comments

Comments
 (0)