Commit 0d6ea790 authored by Andy Wilkinson's avatar Andy Wilkinson

Start building against Spring Framework 5.3.0 snapshots

See gh-21929
parent a0946c89
...@@ -59,12 +59,9 @@ import org.springframework.web.method.HandlerMethod; ...@@ -59,12 +59,9 @@ import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.handler.MatchableHandlerMapping; import org.springframework.web.servlet.handler.MatchableHandlerMapping;
import org.springframework.web.servlet.handler.RequestMatchResult; import org.springframework.web.servlet.handler.RequestMatchResult;
import org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition;
import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
import org.springframework.web.servlet.mvc.condition.ProducesRequestCondition;
import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping; import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
import org.springframework.web.util.UrlPathHelper;
/** /**
* A custom {@link HandlerMapping} that makes {@link ExposableWebEndpoint web endpoints} * A custom {@link HandlerMapping} that makes {@link ExposableWebEndpoint web endpoints}
...@@ -161,7 +158,6 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin ...@@ -161,7 +158,6 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private static RequestMappingInfo.BuilderConfiguration getBuilderConfig() { private static RequestMappingInfo.BuilderConfiguration getBuilderConfig() {
RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration(); RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration();
config.setUrlPathHelper(null);
config.setPathMatcher(null); config.setPathMatcher(null);
config.setSuffixPatternMatch(false); config.setSuffixPatternMatch(false);
config.setTrailingSlashMatch(true); config.setTrailingSlashMatch(true);
...@@ -195,34 +191,21 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin ...@@ -195,34 +191,21 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
} }
private RequestMappingInfo createRequestMappingInfo(WebOperationRequestPredicate predicate, String path) { private RequestMappingInfo createRequestMappingInfo(WebOperationRequestPredicate predicate, String path) {
PatternsRequestCondition patterns = patternsRequestConditionForPattern(path); return RequestMappingInfo.paths(this.endpointMapping.createSubPath(path))
RequestMethodsRequestCondition methods = new RequestMethodsRequestCondition( .methods(RequestMethod.valueOf(predicate.getHttpMethod().name()))
RequestMethod.valueOf(predicate.getHttpMethod().name())); .consumes(predicate.getConsumes().toArray(new String[0]))
ConsumesRequestCondition consumes = new ConsumesRequestCondition( .produces(predicate.getProduces().toArray(new String[0])).build();
StringUtils.toStringArray(predicate.getConsumes()));
ProducesRequestCondition produces = new ProducesRequestCondition(
StringUtils.toStringArray(predicate.getProduces()));
return new RequestMappingInfo(null, patterns, methods, null, null, consumes, produces, null);
} }
private void registerLinksMapping() { private void registerLinksMapping() {
PatternsRequestCondition patterns = patternsRequestConditionForPattern(""); RequestMappingInfo mapping = RequestMappingInfo.paths(this.endpointMapping.createSubPath(""))
RequestMethodsRequestCondition methods = new RequestMethodsRequestCondition(RequestMethod.GET); .methods(RequestMethod.GET).produces(this.endpointMediaTypes.getProduced().toArray(new String[0]))
ProducesRequestCondition produces = new ProducesRequestCondition(this.endpointMediaTypes.getProduced() .options(builderConfig).build();
.toArray(StringUtils.toStringArray(this.endpointMediaTypes.getProduced())));
RequestMappingInfo mapping = new RequestMappingInfo(patterns, methods, null, null, null, produces, null);
LinksHandler linksHandler = getLinksHandler(); LinksHandler linksHandler = getLinksHandler();
registerMapping(mapping, linksHandler, ReflectionUtils.findMethod(linksHandler.getClass(), "links", registerMapping(mapping, linksHandler, ReflectionUtils.findMethod(linksHandler.getClass(), "links",
HttpServletRequest.class, HttpServletResponse.class)); HttpServletRequest.class, HttpServletResponse.class));
} }
@SuppressWarnings("deprecation")
private PatternsRequestCondition patternsRequestConditionForPattern(String path) {
String[] patterns = new String[] { this.endpointMapping.createSubPath(path) };
return new PatternsRequestCondition(patterns, builderConfig.getUrlPathHelper(), builderConfig.getPathMatcher(),
builderConfig.useSuffixPatternMatch(), builderConfig.useTrailingSlashMatch());
}
@Override @Override
protected boolean hasCorsConfigurationSource(Object handler) { protected boolean hasCorsConfigurationSource(Object handler) {
return this.corsConfiguration != null; return this.corsConfiguration != null;
...@@ -332,7 +315,7 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin ...@@ -332,7 +315,7 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
} }
private Object getRemainingPathSegments(HttpServletRequest request) { private Object getRemainingPathSegments(HttpServletRequest request) {
String[] pathTokens = tokenize(request, HandlerMapping.LOOKUP_PATH, true); String[] pathTokens = tokenize(request, UrlPathHelper.PATH_ATTRIBUTE, true);
String[] patternTokens = tokenize(request, HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, false); String[] patternTokens = tokenize(request, HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, false);
int numberOfRemainingPathSegments = pathTokens.length - patternTokens.length + 1; int numberOfRemainingPathSegments = pathTokens.length - patternTokens.length + 1;
Assert.state(numberOfRemainingPathSegments >= 0, "Unable to extract remaining path segments"); Assert.state(numberOfRemainingPathSegments >= 0, "Unable to extract remaining path segments");
......
...@@ -19,16 +19,16 @@ package org.springframework.boot.actuate.endpoint.web.servlet; ...@@ -19,16 +19,16 @@ package org.springframework.boot.actuate.endpoint.web.servlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import org.springframework.web.servlet.HandlerInterceptor;
/** /**
* {@link HandlerInterceptorAdapter} to ensure that * {@link HandlerInterceptor} to ensure that
* {@link org.springframework.web.accept.PathExtensionContentNegotiationStrategy} is * {@link org.springframework.web.accept.PathExtensionContentNegotiationStrategy} is
* skipped for web endpoints. * skipped for web endpoints.
* *
* @author Phillip Webb * @author Phillip Webb
*/ */
final class SkipPathExtensionContentNegotiation extends HandlerInterceptorAdapter { final class SkipPathExtensionContentNegotiation implements HandlerInterceptor {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private static final String SKIP_ATTRIBUTE = org.springframework.web.accept.PathExtensionContentNegotiationStrategy.class private static final String SKIP_ATTRIBUTE = org.springframework.web.accept.PathExtensionContentNegotiationStrategy.class
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -121,6 +121,13 @@ class MvcWebEndpointIntegrationTests ...@@ -121,6 +121,13 @@ class MvcWebEndpointIntegrationTests
context.register(TestEndpointConfiguration.class); context.register(TestEndpointConfiguration.class);
context.refresh(); context.refresh();
WebMvcEndpointHandlerMapping bean = context.getBean(WebMvcEndpointHandlerMapping.class); WebMvcEndpointHandlerMapping bean = context.getBean(WebMvcEndpointHandlerMapping.class);
try {
// Trigger initLookupPath
bean.getHandler(request);
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
return bean.match(request, "/spring"); return bean.match(request, "/spring");
} }
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -128,7 +128,8 @@ public final class StaticResourceRequest { ...@@ -128,7 +128,8 @@ public final class StaticResourceRequest {
} }
private Stream<String> getPatterns() { private Stream<String> getPatterns() {
return this.locations.stream().flatMap(StaticResourceLocation::getPatterns); return this.locations.stream().flatMap(StaticResourceLocation::getPatterns)
.map((pattern) -> pattern.replace("/**/", "/*/"));
} }
@Override @Override
......
...@@ -284,18 +284,6 @@ public class WebMvcAutoConfiguration { ...@@ -284,18 +284,6 @@ public class WebMvcAutoConfiguration {
return resolver; return resolver;
} }
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "spring.mvc", name = "locale")
public LocaleResolver localeResolver() {
if (this.mvcProperties.getLocaleResolver() == WebMvcProperties.LocaleResolver.FIXED) {
return new FixedLocaleResolver(this.mvcProperties.getLocale());
}
AcceptHeaderLocaleResolver localeResolver = new AcceptHeaderLocaleResolver();
localeResolver.setDefaultLocale(this.mvcProperties.getLocale());
return localeResolver;
}
@Override @Override
public MessageCodesResolver getMessageCodesResolver() { public MessageCodesResolver getMessageCodesResolver() {
if (this.mvcProperties.getMessageCodesResolverFormat() != null) { if (this.mvcProperties.getMessageCodesResolverFormat() != null) {
...@@ -420,6 +408,19 @@ public class WebMvcAutoConfiguration { ...@@ -420,6 +408,19 @@ public class WebMvcAutoConfiguration {
return welcomePageHandlerMapping; return welcomePageHandlerMapping;
} }
@Override
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "spring.mvc", name = "locale", matchIfMissing = true)
public LocaleResolver localeResolver() {
if (this.mvcProperties.getLocaleResolver() == WebMvcProperties.LocaleResolver.FIXED) {
return new FixedLocaleResolver(this.mvcProperties.getLocale());
}
AcceptHeaderLocaleResolver localeResolver = new AcceptHeaderLocaleResolver();
localeResolver.setDefaultLocale(this.mvcProperties.getLocale());
return localeResolver;
}
private Optional<Resource> getWelcomePage() { private Optional<Resource> getWelcomePage() {
String[] locations = getResourceLocations(this.resourceProperties.getStaticLocations()); String[] locations = getResourceLocations(this.resourceProperties.getStaticLocations());
return Arrays.stream(locations).map(this::getIndexHtml).filter(this::isReadable).findFirst(); return Arrays.stream(locations).map(this::getIndexHtml).filter(this::isReadable).findFirst();
......
...@@ -28,6 +28,7 @@ import org.springframework.boot.web.codec.CodecCustomizer; ...@@ -28,6 +28,7 @@ import org.springframework.boot.web.codec.CodecCustomizer;
import org.springframework.boot.web.reactive.function.client.WebClientCustomizer; import org.springframework.boot.web.reactive.function.client.WebClientCustomizer;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.http.client.reactive.ClientHttpConnector;
import org.springframework.http.client.reactive.ClientHttpResponse; import org.springframework.http.client.reactive.ClientHttpResponse;
...@@ -87,6 +88,7 @@ class WebClientAutoConfigurationTests { ...@@ -87,6 +88,7 @@ class WebClientAutoConfigurationTests {
void shouldGetPrototypeScopedBean() { void shouldGetPrototypeScopedBean() {
this.contextRunner.withUserConfiguration(WebClientCustomizerConfig.class).run((context) -> { this.contextRunner.withUserConfiguration(WebClientCustomizerConfig.class).run((context) -> {
ClientHttpResponse response = mock(ClientHttpResponse.class); ClientHttpResponse response = mock(ClientHttpResponse.class);
given(response.getHeaders()).willReturn(new HttpHeaders());
ClientHttpConnector firstConnector = mock(ClientHttpConnector.class); ClientHttpConnector firstConnector = mock(ClientHttpConnector.class);
given(firstConnector.connect(any(), any(), any())).willReturn(Mono.just(response)); given(firstConnector.connect(any(), any(), any())).willReturn(Mono.just(response));
WebClient.Builder firstBuilder = context.getBean(WebClient.Builder.class); WebClient.Builder firstBuilder = context.getBean(WebClient.Builder.class);
......
...@@ -277,8 +277,12 @@ class WebMvcAutoConfigurationTests { ...@@ -277,8 +277,12 @@ class WebMvcAutoConfigurationTests {
} }
@Test @Test
void noLocaleResolver() { void defaultLocaleResolver() {
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean(LocaleResolver.class)); this.contextRunner.run((context) -> {
assertThat(context).hasSingleBean(LocaleResolver.class);
LocaleResolver localeResolver = context.getBean(LocaleResolver.class);
assertThat(((AcceptHeaderLocaleResolver) localeResolver).getDefaultLocale()).isNull();
});
} }
@Test @Test
......
...@@ -1679,7 +1679,7 @@ bom { ...@@ -1679,7 +1679,7 @@ bom {
] ]
} }
} }
library("Spring Framework", "5.2.6.RELEASE") { library("Spring Framework", "5.3.0-SNAPSHOT") {
group("org.springframework") { group("org.springframework") {
imports = [ imports = [
"spring-framework-bom" "spring-framework-bom"
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -28,7 +28,7 @@ import org.springframework.beans.BeanUtils; ...@@ -28,7 +28,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter; import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
...@@ -163,7 +163,7 @@ public class JsonTestersAutoConfiguration { ...@@ -163,7 +163,7 @@ public class JsonTestersAutoConfiguration {
/** /**
* {@link BeanPostProcessor} used to initialize JSON testers. * {@link BeanPostProcessor} used to initialize JSON testers.
*/ */
static class JsonMarshalTestersBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter { static class JsonMarshalTestersBeanPostProcessor implements InstantiationAwareBeanPostProcessor {
@Override @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -48,8 +48,7 @@ public class ExampleRepository { ...@@ -48,8 +48,7 @@ public class ExampleRepository {
} }
public ExampleEntity findById(int id) { public ExampleEntity findById(int id) {
return this.jdbcTemplate.queryForObject("select id, name from example where id =?", new Object[] { id }, return this.jdbcTemplate.queryForObject("select id, name from example where id =?", ROW_MAPPER, id);
ROW_MAPPER);
} }
public Collection<ExampleEntity> findAll() { public Collection<ExampleEntity> findAll() {
......
...@@ -73,7 +73,7 @@ class DataJpaTestIntegrationTests { ...@@ -73,7 +73,7 @@ class DataJpaTestIntegrationTests {
Long id = this.entities.persistAndGetId(new ExampleEntity("spring", "123"), Long.class); Long id = this.entities.persistAndGetId(new ExampleEntity("spring", "123"), Long.class);
assertThat(id).isNotNull(); assertThat(id).isNotNull();
String reference = this.jdbcTemplate.queryForObject("SELECT REFERENCE FROM EXAMPLE_ENTITY WHERE ID = ?", String reference = this.jdbcTemplate.queryForObject("SELECT REFERENCE FROM EXAMPLE_ENTITY WHERE ID = ?",
new Object[] { id }, String.class); String.class, id);
assertThat(reference).isEqualTo("123"); assertThat(reference).isEqualTo("123");
} }
......
...@@ -43,8 +43,9 @@ import org.springframework.beans.factory.config.BeanPostProcessor; ...@@ -43,8 +43,9 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.ConstructorArgumentValues; import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter; import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator; import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.beans.factory.support.DefaultBeanNameGenerator; import org.springframework.beans.factory.support.DefaultBeanNameGenerator;
...@@ -75,8 +76,8 @@ import org.springframework.util.StringUtils; ...@@ -75,8 +76,8 @@ import org.springframework.util.StringUtils;
* @author Andreas Neiser * @author Andreas Neiser
* @since 1.4.0 * @since 1.4.0
*/ */
public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAdapter public class MockitoPostProcessor implements InstantiationAwareBeanPostProcessor, BeanClassLoaderAware,
implements BeanClassLoaderAware, BeanFactoryAware, BeanFactoryPostProcessor, Ordered { BeanFactoryAware, BeanFactoryPostProcessor, Ordered {
private static final String BEAN_NAME = MockitoPostProcessor.class.getName(); private static final String BEAN_NAME = MockitoPostProcessor.class.getName();
...@@ -424,7 +425,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda ...@@ -424,7 +425,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
* {@link BeanPostProcessor} to handle {@link SpyBean} definitions. Registered as a * {@link BeanPostProcessor} to handle {@link SpyBean} definitions. Registered as a
* separate processor so that it can be ordered above AOP post processors. * separate processor so that it can be ordered above AOP post processors.
*/ */
static class SpyPostProcessor extends InstantiationAwareBeanPostProcessorAdapter implements PriorityOrdered { static class SpyPostProcessor implements SmartInstantiationAwareBeanPostProcessor, PriorityOrdered {
private static final String BEAN_NAME = SpyPostProcessor.class.getName(); private static final String BEAN_NAME = SpyPostProcessor.class.getName();
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -48,11 +48,11 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -48,11 +48,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
...@@ -150,7 +150,7 @@ class ErrorPageFilterIntegrationTests { ...@@ -150,7 +150,7 @@ class ErrorPageFilterIntegrationTests {
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new HandlerInterceptorAdapter() { registry.addInterceptor(new HandlerInterceptor() {
@Override @Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) { ModelAndView modelAndView) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment