Merge branch '5.2.x'

# Conflicts:
#	build.gradle
This commit is contained in:
Juergen Hoeller
2020-07-17 17:52:08 +02:00
16 changed files with 187 additions and 122 deletions

View File

@@ -16,7 +16,6 @@
package org.springframework.web.reactive.config;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -29,6 +28,7 @@ import org.springframework.web.cors.CorsConfiguration;
* @author Sebastien Deleuze
* @author Rossen Stoyanchev
* @since 5.0
* @see CorsConfiguration
* @see CorsRegistry
*/
public class CorsRegistration {
@@ -40,6 +40,7 @@ public class CorsRegistration {
public CorsRegistration(String pathPattern) {
this.pathPattern = pathPattern;
// Same implicit default values as the @CrossOrigin annotation + allows simple methods
this.config = new CorsConfiguration().applyPermitDefaultValues();
}
@@ -51,7 +52,7 @@ public class CorsRegistration {
* also set in which case {@code originPatterns} is used instead.
*/
public CorsRegistration allowedOrigins(String... origins) {
this.config.setAllowedOrigins(new ArrayList<>(Arrays.asList(origins)));
this.config.setAllowedOrigins(Arrays.asList(origins));
return this;
}
@@ -74,7 +75,7 @@ public class CorsRegistration {
* are allowed.
*/
public CorsRegistration allowedMethods(String... methods) {
this.config.setAllowedMethods(new ArrayList<>(Arrays.asList(methods)));
this.config.setAllowedMethods(Arrays.asList(methods));
return this;
}
@@ -88,7 +89,7 @@ public class CorsRegistration {
* <p>By default all headers are allowed.
*/
public CorsRegistration allowedHeaders(String... headers) {
this.config.setAllowedHeaders(new ArrayList<>(Arrays.asList(headers)));
this.config.setAllowedHeaders(Arrays.asList(headers));
return this;
}
@@ -101,7 +102,7 @@ public class CorsRegistration {
* <p>By default this is not set.
*/
public CorsRegistration exposedHeaders(String... headers) {
this.config.setExposedHeaders(new ArrayList<>(Arrays.asList(headers)));
this.config.setExposedHeaders(Arrays.asList(headers));
return this;
}

View File

@@ -37,11 +37,9 @@ public class CorsRegistry {
/**
* Enable cross origin request handling for the specified path pattern.
*
* Enable cross-origin request handling for the specified path pattern.
* <p>Exact path mapping URIs (such as {@code "/admin"}) are supported as
* well as Ant-style path patterns (such as {@code "/admin/**"}).
*
* <p>By default, the {@code CorsConfiguration} for this mapping is
* initialized with default values as described in
* {@link CorsConfiguration#applyPermitDefaultValues()}.
@@ -52,6 +50,10 @@ public class CorsRegistry {
return registration;
}
/**
* Return the registered {@link CorsConfiguration} objects,
* keyed by path pattern.
*/
protected Map<String, CorsConfiguration> getCorsConfigurations() {
Map<String, CorsConfiguration> configs = new LinkedHashMap<>(this.registrations.size());
for (CorsRegistration registration : this.registrations) {

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -169,7 +169,7 @@ class ControllerMethodResolver {
boolean requestMappingMethod = !readers.isEmpty() && supportDataBinding;
// Annotation-based...
List<HandlerMethodArgumentResolver> result = new ArrayList<>();
List<HandlerMethodArgumentResolver> result = new ArrayList<>(30);
result.add(new RequestParamMethodArgumentResolver(beanFactory, adapterRegistry, false));
result.add(new RequestParamMapMethodArgumentResolver(adapterRegistry));
result.add(new PathVariableMethodArgumentResolver(beanFactory, adapterRegistry));

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,6 @@ import org.springframework.web.server.ServerWebInputException;
*/
public class RequestAttributeMethodArgumentResolver extends AbstractNamedValueSyncArgumentResolver {
/**
* Create a new {@link RequestAttributeMethodArgumentResolver} instance.
* @param factory a bean factory to use for resolving {@code ${...}}