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