diff --git a/spring-context/src/main/java/org/springframework/ejb/config/AbstractJndiLocatingBeanDefinitionParser.java b/spring-context/src/main/java/org/springframework/ejb/config/AbstractJndiLocatingBeanDefinitionParser.java index 51e9a3fff95..34c4ac5c9ad 100644 --- a/spring-context/src/main/java/org/springframework/ejb/config/AbstractJndiLocatingBeanDefinitionParser.java +++ b/spring-context/src/main/java/org/springframework/ejb/config/AbstractJndiLocatingBeanDefinitionParser.java @@ -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. @@ -49,8 +49,9 @@ abstract class AbstractJndiLocatingBeanDefinitionParser extends AbstractSimpleBe @Override protected boolean isEligibleAttribute(String attributeName) { - return (super.isEligibleAttribute(attributeName) && !ENVIRONMENT_REF.equals(attributeName) && !LAZY_INIT_ATTRIBUTE - .equals(attributeName)); + return (super.isEligibleAttribute(attributeName) && + !ENVIRONMENT_REF.equals(attributeName) && + !LAZY_INIT_ATTRIBUTE.equals(attributeName)); } @Override diff --git a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java index 2b4ac0d08c0..ec9662810e6 100644 --- a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java @@ -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. @@ -42,8 +42,9 @@ public class JeeNamespaceHandlerTests { private ConfigurableListableBeanFactory beanFactory; + @BeforeEach - public void setUp() throws Exception { + public void setup() { GenericApplicationContext ctx = new GenericApplicationContext(); new XmlBeanDefinitionReader(ctx).loadBeanDefinitions( new ClassPathResource("jeeNamespaceHandlerTests.xml", getClass())); @@ -52,8 +53,9 @@ public class JeeNamespaceHandlerTests { this.beanFactory.getBeanNamesForType(ITestBean.class); } + @Test - public void testSimpleDefinition() throws Exception { + public void testSimpleDefinition() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simple"); assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName()); assertPropertyValue(beanDefinition, "jndiName", "jdbc/MyDataSource"); @@ -61,7 +63,7 @@ public class JeeNamespaceHandlerTests { } @Test - public void testComplexDefinition() throws Exception { + public void testComplexDefinition() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complex"); assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName()); assertPropertyValue(beanDefinition, "jndiName", "jdbc/MyDataSource"); @@ -75,21 +77,21 @@ public class JeeNamespaceHandlerTests { } @Test - public void testWithEnvironment() throws Exception { + public void testWithEnvironment() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("withEnvironment"); assertPropertyValue(beanDefinition, "jndiEnvironment", "foo=bar"); assertPropertyValue(beanDefinition, "defaultObject", new RuntimeBeanReference("myBean")); } @Test - public void testWithReferencedEnvironment() throws Exception { + public void testWithReferencedEnvironment() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("withReferencedEnvironment"); assertPropertyValue(beanDefinition, "jndiEnvironment", new RuntimeBeanReference("myEnvironment")); assertThat(beanDefinition.getPropertyValues().contains("environmentRef")).isFalse(); } @Test - public void testSimpleLocalSlsb() throws Exception { + public void testSimpleLocalSlsb() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleLocalEjb"); assertThat(beanDefinition.getBeanClassName()).isEqualTo(LocalStatelessSessionProxyFactoryBean.class.getName()); assertPropertyValue(beanDefinition, "businessInterface", ITestBean.class.getName()); @@ -97,7 +99,7 @@ public class JeeNamespaceHandlerTests { } @Test - public void testSimpleRemoteSlsb() throws Exception { + public void testSimpleRemoteSlsb() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleRemoteEjb"); assertThat(beanDefinition.getBeanClassName()).isEqualTo(SimpleRemoteStatelessSessionProxyFactoryBean.class.getName()); assertPropertyValue(beanDefinition, "businessInterface", ITestBean.class.getName()); @@ -105,7 +107,7 @@ public class JeeNamespaceHandlerTests { } @Test - public void testComplexLocalSlsb() throws Exception { + public void testComplexLocalSlsb() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexLocalEjb"); assertThat(beanDefinition.getBeanClassName()).isEqualTo(LocalStatelessSessionProxyFactoryBean.class.getName()); assertPropertyValue(beanDefinition, "businessInterface", ITestBean.class.getName()); @@ -117,7 +119,7 @@ public class JeeNamespaceHandlerTests { } @Test - public void testComplexRemoteSlsb() throws Exception { + public void testComplexRemoteSlsb() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexRemoteEjb"); assertThat(beanDefinition.getBeanClassName()).isEqualTo(SimpleRemoteStatelessSessionProxyFactoryBean.class.getName()); assertPropertyValue(beanDefinition, "businessInterface", ITestBean.class.getName()); @@ -132,7 +134,7 @@ public class JeeNamespaceHandlerTests { } @Test - public void testLazyInitJndiLookup() throws Exception { + public void testLazyInitJndiLookup() { BeanDefinition definition = this.beanFactory.getMergedBeanDefinition("lazyDataSource"); assertThat(definition.isLazyInit()).isTrue(); definition = this.beanFactory.getMergedBeanDefinition("lazyLocalBean"); diff --git a/spring-web/src/main/java/org/springframework/web/bind/annotation/RequestMapping.java b/spring-web/src/main/java/org/springframework/web/bind/annotation/RequestMapping.java index f54a8db1f23..a0e357e8f86 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/annotation/RequestMapping.java +++ b/spring-web/src/main/java/org/springframework/web/bind/annotation/RequestMapping.java @@ -202,7 +202,7 @@ public @interface RequestMapping { * produces = "text/plain;charset=UTF-8" * *
If a declared media type contains a parameter (e.g. "charset=UTF-8", - * "type=feed", type="entry") and if a compatible media type from the request + * "type=feed", "type=entry") and if a compatible media type from the request * has that parameter too, then the parameter values must match. Otherwise * if the media type from the request does not contain the parameter, it is * assumed the client accepts any value. @@ -212,7 +212,6 @@ public @interface RequestMapping { * If specified at both levels, the method level produces condition overrides * the type level condition. * @see org.springframework.http.MediaType - * @see org.springframework.http.MediaType */ String[] produces() default {}; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/config/CorsRegistration.java b/spring-webflux/src/main/java/org/springframework/web/reactive/config/CorsRegistration.java index 8dad2ae07fc..096935e79da 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/config/CorsRegistration.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/config/CorsRegistration.java @@ -16,7 +16,6 @@ package org.springframework.web.reactive.config; -import java.util.ArrayList; import java.util.Arrays; import org.springframework.web.cors.CorsConfiguration; @@ -28,6 +27,7 @@ import org.springframework.web.cors.CorsConfiguration; * @author Sebastien Deleuze * @author Rossen Stoyanchev * @since 5.0 + * @see CorsConfiguration * @see CorsRegistry */ public class CorsRegistration { @@ -39,6 +39,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(); } @@ -58,7 +59,7 @@ public class CorsRegistration { * See the Spring Framework reference for more on this filter. */ public CorsRegistration allowedOrigins(String... origins) { - this.config.setAllowedOrigins(new ArrayList<>(Arrays.asList(origins))); + this.config.setAllowedOrigins(Arrays.asList(origins)); return this; } @@ -69,7 +70,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; } @@ -83,7 +84,7 @@ public class CorsRegistration { *
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; } @@ -96,7 +97,7 @@ public class CorsRegistration { *
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; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/config/CorsRegistry.java b/spring-webflux/src/main/java/org/springframework/web/reactive/config/CorsRegistry.java index b0b817d2693..263e66c15ee 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/config/CorsRegistry.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/config/CorsRegistry.java @@ -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. *
Exact path mapping URIs (such as {@code "/admin"}) are supported as * well as Ant-style path patterns (such as {@code "/admin/**"}). - * *
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 By default "simple" methods, i.e. {@code GET}, {@code HEAD}, and
- * {@code POST} are allowed.
+ * The special value {@code "*"} allows all methods.
+ * By default "simple" methods {@code GET}, {@code HEAD}, and {@code POST}
+ * are allowed.
*/
public CorsRegistration allowedMethods(String... methods) {
this.config.setAllowedMethods(Arrays.asList(methods));
@@ -77,9 +77,9 @@ public class CorsRegistration {
}
/**
- * Set the list of headers that a preflight request can list as allowed
- * for use during an actual request. The special value {@code "*"} may be
- * used to allow all headers.
+ * Set the list of headers that a pre-flight request can list as allowed
+ * for use during an actual request.
+ * The special value {@code "*"} may be used to allow all headers.
* A header name is not required to be listed if it is one of:
* {@code Cache-Control}, {@code Content-Language}, {@code Expires},
* {@code Last-Modified}, or {@code Pragma} as per the CORS spec.
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/CorsRegistry.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/CorsRegistry.java
index da4c1493ad8..ad93c973ac9 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/CorsRegistry.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/CorsRegistry.java
@@ -39,10 +39,8 @@ public class CorsRegistry {
/**
* Enable cross-origin request handling for the specified path pattern.
- *
* Exact path mapping URIs (such as {@code "/admin"}) are supported as
* well as Ant-style path patterns (such as {@code "/admin/**"}).
- *
* By default, the {@code CorsConfiguration} for this mapping is
* initialized with default values as described in
* {@link CorsConfiguration#applyPermitDefaultValues()}.
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java
index 66049d310e0..a3b09fa17c3 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java
@@ -151,7 +151,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
private List