Merge branch '5.2.x'
# Conflicts: # build.gradle # spring-tx/src/main/java/org/springframework/dao/support/PersistenceExceptionTranslationInterceptor.java # spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java # spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerExecutionChain.java # spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java
This commit is contained in:
commit
f4c0ceb1cc
|
|
@ -325,9 +325,9 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||||
this.allowBeanDefinitionOverriding = otherListableFactory.allowBeanDefinitionOverriding;
|
this.allowBeanDefinitionOverriding = otherListableFactory.allowBeanDefinitionOverriding;
|
||||||
this.allowEagerClassLoading = otherListableFactory.allowEagerClassLoading;
|
this.allowEagerClassLoading = otherListableFactory.allowEagerClassLoading;
|
||||||
this.dependencyComparator = otherListableFactory.dependencyComparator;
|
this.dependencyComparator = otherListableFactory.dependencyComparator;
|
||||||
// A clone of the AutowireCandidateResolver since it is potentially BeanFactoryAware...
|
// A clone of the AutowireCandidateResolver since it is potentially BeanFactoryAware
|
||||||
setAutowireCandidateResolver(otherListableFactory.getAutowireCandidateResolver().cloneIfNecessary());
|
setAutowireCandidateResolver(otherListableFactory.getAutowireCandidateResolver().cloneIfNecessary());
|
||||||
// Make resolvable dependencies (e.g. ResourceLoader) available here as well...
|
// Make resolvable dependencies (e.g. ResourceLoader) available here as well
|
||||||
this.resolvableDependencies.putAll(otherListableFactory.resolvableDependencies);
|
this.resolvableDependencies.putAll(otherListableFactory.resolvableDependencies);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -462,6 +462,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Stream<T> stream() {
|
public Stream<T> stream() {
|
||||||
|
|
@ -469,6 +470,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||||
.map(name -> (T) getBean(name))
|
.map(name -> (T) getBean(name))
|
||||||
.filter(bean -> !(bean instanceof NullBean));
|
.filter(bean -> !(bean instanceof NullBean));
|
||||||
}
|
}
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Stream<T> orderedStream() {
|
public Stream<T> orderedStream() {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-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.
|
||||||
|
|
@ -55,8 +55,7 @@ public abstract class AbstractValueAdaptingCache implements Cache {
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public ValueWrapper get(Object key) {
|
public ValueWrapper get(Object key) {
|
||||||
Object value = lookup(key);
|
return toValueWrapper(lookup(key));
|
||||||
return toValueWrapper(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-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.
|
||||||
|
|
@ -52,7 +52,7 @@ public class FileUrlResource extends UrlResource implements WritableResource {
|
||||||
/**
|
/**
|
||||||
* Create a new {@code FileUrlResource} based on the given URL object.
|
* Create a new {@code FileUrlResource} based on the given URL object.
|
||||||
* <p>Note that this does not enforce "file" as URL protocol. If a protocol
|
* <p>Note that this does not enforce "file" as URL protocol. If a protocol
|
||||||
* is known to be resolvable to a file,
|
* is known to be resolvable to a file, it is acceptable for this purpose.
|
||||||
* @param url a URL
|
* @param url a URL
|
||||||
* @see ResourceUtils#isFileURL(URL)
|
* @see ResourceUtils#isFileURL(URL)
|
||||||
* @see #getFile()
|
* @see #getFile()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-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.
|
||||||
|
|
@ -56,7 +56,8 @@ public class UrlResource extends AbstractFileResolvingResource {
|
||||||
/**
|
/**
|
||||||
* Cleaned URL (with normalized path), used for comparisons.
|
* Cleaned URL (with normalized path), used for comparisons.
|
||||||
*/
|
*/
|
||||||
private final URL cleanedUrl;
|
@Nullable
|
||||||
|
private volatile URL cleanedUrl;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -69,7 +70,6 @@ public class UrlResource extends AbstractFileResolvingResource {
|
||||||
Assert.notNull(uri, "URI must not be null");
|
Assert.notNull(uri, "URI must not be null");
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
this.url = uri.toURL();
|
this.url = uri.toURL();
|
||||||
this.cleanedUrl = getCleanedUrl(this.url, uri.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -78,9 +78,8 @@ public class UrlResource extends AbstractFileResolvingResource {
|
||||||
*/
|
*/
|
||||||
public UrlResource(URL url) {
|
public UrlResource(URL url) {
|
||||||
Assert.notNull(url, "URL must not be null");
|
Assert.notNull(url, "URL must not be null");
|
||||||
this.url = url;
|
|
||||||
this.cleanedUrl = getCleanedUrl(this.url, url.toString());
|
|
||||||
this.uri = null;
|
this.uri = null;
|
||||||
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -127,7 +126,6 @@ public class UrlResource extends AbstractFileResolvingResource {
|
||||||
try {
|
try {
|
||||||
this.uri = new URI(protocol, location, fragment);
|
this.uri = new URI(protocol, location, fragment);
|
||||||
this.url = this.uri.toURL();
|
this.url = this.uri.toURL();
|
||||||
this.cleanedUrl = getCleanedUrl(this.url, this.uri.toString());
|
|
||||||
}
|
}
|
||||||
catch (URISyntaxException ex) {
|
catch (URISyntaxException ex) {
|
||||||
MalformedURLException exToThrow = new MalformedURLException(ex.getMessage());
|
MalformedURLException exToThrow = new MalformedURLException(ex.getMessage());
|
||||||
|
|
@ -144,7 +142,7 @@ public class UrlResource extends AbstractFileResolvingResource {
|
||||||
* @return the cleaned URL (possibly the original URL as-is)
|
* @return the cleaned URL (possibly the original URL as-is)
|
||||||
* @see org.springframework.util.StringUtils#cleanPath
|
* @see org.springframework.util.StringUtils#cleanPath
|
||||||
*/
|
*/
|
||||||
private URL getCleanedUrl(URL originalUrl, String originalPath) {
|
private static URL getCleanedUrl(URL originalUrl, String originalPath) {
|
||||||
String cleanedPath = StringUtils.cleanPath(originalPath);
|
String cleanedPath = StringUtils.cleanPath(originalPath);
|
||||||
if (!cleanedPath.equals(originalPath)) {
|
if (!cleanedPath.equals(originalPath)) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -157,6 +155,21 @@ public class UrlResource extends AbstractFileResolvingResource {
|
||||||
return originalUrl;
|
return originalUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lazily determine a cleaned URL for the given original URL.
|
||||||
|
* @see #getCleanedUrl(URL, String)
|
||||||
|
*/
|
||||||
|
private URL getCleanedUrl() {
|
||||||
|
URL cleanedUrl = this.cleanedUrl;
|
||||||
|
if (cleanedUrl != null) {
|
||||||
|
return cleanedUrl;
|
||||||
|
}
|
||||||
|
cleanedUrl = getCleanedUrl(this.url, (this.uri != null ? this.uri : this.url).toString());
|
||||||
|
this.cleanedUrl = cleanedUrl;
|
||||||
|
return cleanedUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This implementation opens an InputStream for the given URL.
|
* This implementation opens an InputStream for the given URL.
|
||||||
* <p>It sets the {@code useCaches} flag to {@code false},
|
* <p>It sets the {@code useCaches} flag to {@code false},
|
||||||
|
|
@ -262,7 +275,7 @@ public class UrlResource extends AbstractFileResolvingResource {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getFilename() {
|
public String getFilename() {
|
||||||
return StringUtils.getFilename(this.cleanedUrl.getPath());
|
return StringUtils.getFilename(getCleanedUrl().getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -280,7 +293,7 @@ public class UrlResource extends AbstractFileResolvingResource {
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object other) {
|
public boolean equals(@Nullable Object other) {
|
||||||
return (this == other || (other instanceof UrlResource &&
|
return (this == other || (other instanceof UrlResource &&
|
||||||
this.cleanedUrl.equals(((UrlResource) other).cleanedUrl)));
|
getCleanedUrl().equals(((UrlResource) other).getCleanedUrl())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -288,7 +301,7 @@ public class UrlResource extends AbstractFileResolvingResource {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return this.cleanedUrl.hashCode();
|
return getCleanedUrl().hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-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.
|
||||||
|
|
@ -18,6 +18,7 @@ package org.springframework.jdbc.datasource.lookup;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -164,6 +165,29 @@ public abstract class AbstractRoutingDataSource extends AbstractDataSource imple
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the resolved target DataSources that this router manages.
|
||||||
|
* @return an unmodifiable map of resolved lookup keys and DataSources
|
||||||
|
* @throws IllegalStateException if the target DataSources are not resolved yet
|
||||||
|
* @since 5.2.9
|
||||||
|
* @see #setTargetDataSources
|
||||||
|
*/
|
||||||
|
public Map<Object, DataSource> getResolvedDataSources() {
|
||||||
|
Assert.state(this.resolvedDataSources != null, "DataSources not resolved yet - call afterPropertiesSet");
|
||||||
|
return Collections.unmodifiableMap(this.resolvedDataSources);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the resolved default target DataSource, if any.
|
||||||
|
* @return the default DataSource, or {@code null} if none or not resolved yet
|
||||||
|
* @since 5.2.9
|
||||||
|
* @see #setDefaultTargetDataSource
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public DataSource getResolvedDefaultDataSource() {
|
||||||
|
return this.resolvedDefaultDataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection getConnection() throws SQLException {
|
public Connection getConnection() throws SQLException {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-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.
|
||||||
|
|
@ -60,7 +60,7 @@ public class RSocketRequesterMethodArgumentResolver implements HandlerMethodArgu
|
||||||
return Mono.just(requester);
|
return Mono.just(requester);
|
||||||
}
|
}
|
||||||
else if (RSocket.class.isAssignableFrom(type)) {
|
else if (RSocket.class.isAssignableFrom(type)) {
|
||||||
return Mono.just(requester.rsocket());
|
return Mono.justOrEmpty(requester.rsocket());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return Mono.error(new IllegalArgumentException("Unexpected parameter type: " + parameter));
|
return Mono.error(new IllegalArgumentException("Unexpected parameter type: " + parameter));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-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.
|
||||||
|
|
@ -85,7 +85,6 @@ public class PathVariableMethodArgumentResolver extends AbstractNamedValueSyncAr
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected Object resolveNamedValue(String name, MethodParameter parameter, ServerWebExchange exchange) {
|
protected Object resolveNamedValue(String name, MethodParameter parameter, ServerWebExchange exchange) {
|
||||||
String attributeName = HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE;
|
String attributeName = HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE;
|
||||||
return exchange.getAttributeOrDefault(attributeName, Collections.emptyMap()).get(name);
|
return exchange.getAttributeOrDefault(attributeName, Collections.emptyMap()).get(name);
|
||||||
|
|
@ -97,7 +96,6 @@ public class PathVariableMethodArgumentResolver extends AbstractNamedValueSyncAr
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected void handleResolvedValue(
|
protected void handleResolvedValue(
|
||||||
@Nullable Object arg, String name, MethodParameter parameter, Model model, ServerWebExchange exchange) {
|
@Nullable Object arg, String name, MethodParameter parameter, Model model, ServerWebExchange exchange) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -444,8 +444,8 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the adapted interceptors as {@link HandlerInterceptor} array.
|
* Return the adapted interceptors as {@link HandlerInterceptor} array.
|
||||||
* @return the array of {@link HandlerInterceptor HandlerInterceptors}, or
|
* @return the array of {@link HandlerInterceptor HandlerInterceptor}s,
|
||||||
* {@code null} if none
|
* or {@code null} if none
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
protected final HandlerInterceptor[] getAdaptedInterceptors() {
|
protected final HandlerInterceptor[] getAdaptedInterceptors() {
|
||||||
|
|
@ -572,7 +572,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
|
||||||
* Build a {@link HandlerExecutionChain} for the given handler, including
|
* Build a {@link HandlerExecutionChain} for the given handler, including
|
||||||
* applicable interceptors.
|
* applicable interceptors.
|
||||||
* <p>The default implementation builds a standard {@link HandlerExecutionChain}
|
* <p>The default implementation builds a standard {@link HandlerExecutionChain}
|
||||||
* with the given handler, the handler mappings common interceptors, and any
|
* with the given handler, the common interceptors of the handler mapping, and any
|
||||||
* {@link MappedInterceptor MappedInterceptors} matching to the current request URL. Interceptors
|
* {@link MappedInterceptor MappedInterceptors} matching to the current request URL. Interceptors
|
||||||
* are added in the order they were registered. Subclasses may override this
|
* are added in the order they were registered. Subclasses may override this
|
||||||
* in order to extend/rearrange the list of interceptors.
|
* in order to extend/rearrange the list of interceptors.
|
||||||
|
|
@ -652,7 +652,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
|
||||||
HandlerExecutionChain chain, @Nullable CorsConfiguration config) {
|
HandlerExecutionChain chain, @Nullable CorsConfiguration config) {
|
||||||
|
|
||||||
if (CorsUtils.isPreFlightRequest(request)) {
|
if (CorsUtils.isPreFlightRequest(request)) {
|
||||||
List<HandlerInterceptor> interceptors = chain.getInterceptorList();
|
HandlerInterceptor[] interceptors = chain.getInterceptors();
|
||||||
return new HandlerExecutionChain(new PreFlightHandler(config), interceptors);
|
return new HandlerExecutionChain(new PreFlightHandler(config), interceptors);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-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.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue