} definitions within Spring XML files. It is also possible to
* import Spring XML configuration files into {@code @Configuration} classes using
* the {@link ImportResource @ImportResource} annotation. Bean definitions imported from
- * XML can be injected the usual way (e.g. using the {@code Inject} annotation):
+ * XML can be injected — for example, using the {@code @Inject} annotation:
*
*
* @Configuration
@@ -295,7 +308,7 @@ import org.springframework.stereotype.Component;
*
* With nested {@code @Configuration} classes
*
- * {@code @Configuration} classes may be nested within one another as follows:
+ * {@code @Configuration} classes may be nested within one another as follows:
*
*
* @Configuration
@@ -317,11 +330,11 @@ import org.springframework.stereotype.Component;
* }
* }
*
- * When bootstrapping such an arrangement, only {@code AppConfig} need be registered
+ * When bootstrapping such an arrangement, only {@code AppConfig} need be registered
* against the application context. By virtue of being a nested {@code @Configuration}
* class, {@code DatabaseConfig} will be registered automatically. This avoids
* the need to use an {@code @Import} annotation when the relationship between
- * {@code AppConfig} {@code DatabaseConfig} is already implicitly clear.
+ * {@code AppConfig} and {@code DatabaseConfig} is already implicitly clear.
*
*
Note also that nested {@code @Configuration} classes can be used to good effect
* with the {@code @Profile} annotation to provide two options of the same bean to the
@@ -337,13 +350,13 @@ import org.springframework.stereotype.Component;
*
*
Testing support for {@code @Configuration} classes
*
- * The Spring TestContext framework available in the {@code spring-test} module
- * provides the {@code @ContextConfiguration} annotation, which as of Spring 3.1 can
- * accept an array of {@code @Configuration} {@code Class} objects:
+ * The Spring TestContext framework available in the {@code spring-test} module
+ * provides the {@code @ContextConfiguration} annotation which can accept an array of
+ * {@code @Configuration} {@code Class} objects:
*
*
- * @RunWith(SpringJUnit4ClassRunner.class)
- * @ContextConfiguration(classes={AppConfig.class, DatabaseConfig.class})
+ * @RunWith(SpringRunner.class)
+ * @ContextConfiguration(classes = {AppConfig.class, DatabaseConfig.class})
* public class MyTests {
*
* @Autowired MyBean myBean;
@@ -356,14 +369,16 @@ import org.springframework.stereotype.Component;
* }
* }
*
- * See TestContext framework reference documentation for details.
+ * See the
+ * TestContext framework
+ * reference documentation for details.
*
*
Enabling built-in Spring features using {@code @Enable} annotations
*
- * Spring features such as asynchronous method execution, scheduled task execution,
+ * Spring features such as asynchronous method execution, scheduled task execution,
* annotation driven transaction management, and even Spring MVC can be enabled and
- * configured from {@code @Configuration}
- * classes using their respective "{@code @Enable}" annotations. See
+ * configured from {@code @Configuration} classes using their respective "{@code @Enable}"
+ * annotations. See
* {@link org.springframework.scheduling.annotation.EnableAsync @EnableAsync},
* {@link org.springframework.scheduling.annotation.EnableScheduling @EnableScheduling},
* {@link org.springframework.transaction.annotation.EnableTransactionManagement @EnableTransactionManagement},
@@ -406,15 +421,16 @@ import org.springframework.stereotype.Component;
public @interface Configuration {
/**
- * Explicitly specify the name of the Spring bean definition associated
- * with this Configuration class. If left unspecified (the common case),
- * a bean name will be automatically generated.
- *
The custom name applies only if the Configuration class is picked up via
- * component scanning or supplied directly to a {@link AnnotationConfigApplicationContext}.
- * If the Configuration class is registered as a traditional XML bean definition,
- * the name/id of the bean element will take precedence.
- * @return the suggested component name, if any (or empty String otherwise)
- * @see org.springframework.beans.factory.support.DefaultBeanNameGenerator
+ * Explicitly specify the name of the Spring bean definition associated with the
+ * {@code @Configuration} class. If left unspecified (the common case), a bean
+ * name will be automatically generated.
+ *
The custom name applies only if the {@code @Configuration} class is picked
+ * up via component scanning or supplied directly to an
+ * {@link AnnotationConfigApplicationContext}. If the {@code @Configuration} class
+ * is registered as a traditional XML bean definition, the name/id of the bean
+ * element will take precedence.
+ * @return the explicit component name, if any (or empty String otherwise)
+ * @see AnnotationBeanNameGenerator
*/
@AliasFor(annotation = Component.class)
String value() default "";
diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/KeyHolder.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/KeyHolder.java
index 63c8d05a12..57f65c878c 100644
--- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/KeyHolder.java
+++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/KeyHolder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -30,7 +30,7 @@ import org.springframework.lang.Nullable;
* In the general case, the keys are returned as a List containing one Map
* for each row of keys.
*
- *
Most applications only use on key per row and process only one row at a
+ *
Most applications only use one key per row and process only one row at a
* time in an insert statement. In these cases, just call {@code getKey}
* to retrieve the key. The returned value is a Number here, which is the
* usual type for auto-generated keys.
diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java
index 4edec32b0c..952523d33f 100644
--- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java
+++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -33,12 +33,12 @@ import static org.junit.Assert.*;
public class BeanPropertySqlParameterSourceTests {
@Test(expected = IllegalArgumentException.class)
- public void withNullBeanPassedToCtor() throws Exception {
+ public void withNullBeanPassedToCtor() {
new BeanPropertySqlParameterSource(null);
}
@Test(expected = IllegalArgumentException.class)
- public void getValueWhereTheUnderlyingBeanHasNoSuchProperty() throws Exception {
+ public void getValueWhereTheUnderlyingBeanHasNoSuchProperty() {
BeanPropertySqlParameterSource source = new BeanPropertySqlParameterSource(new TestBean());
source.getValue("thisPropertyDoesNotExist");
}
@@ -65,19 +65,19 @@ public class BeanPropertySqlParameterSourceTests {
}
@Test
- public void hasValueWhereTheUnderlyingBeanHasNoSuchProperty() throws Exception {
+ public void hasValueWhereTheUnderlyingBeanHasNoSuchProperty() {
BeanPropertySqlParameterSource source = new BeanPropertySqlParameterSource(new TestBean());
assertFalse(source.hasValue("thisPropertyDoesNotExist"));
}
@Test(expected = IllegalArgumentException.class)
- public void getValueWhereTheUnderlyingBeanPropertyIsNotReadable() throws Exception {
+ public void getValueWhereTheUnderlyingBeanPropertyIsNotReadable() {
BeanPropertySqlParameterSource source = new BeanPropertySqlParameterSource(new NoReadableProperties());
source.getValue("noOp");
}
@Test
- public void hasValueWhereTheUnderlyingBeanPropertyIsNotReadable() throws Exception {
+ public void hasValueWhereTheUnderlyingBeanPropertyIsNotReadable() {
BeanPropertySqlParameterSource source = new BeanPropertySqlParameterSource(new NoReadableProperties());
assertFalse(source.hasValue("noOp"));
}
diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSourceTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSourceTests.java
index 7c92668930..7140c1722e 100644
--- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSourceTests.java
+++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSourceTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2006 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -29,18 +29,18 @@ import static org.junit.Assert.*;
public class MapSqlParameterSourceTests {
@Test
- public void nullParameterValuesPassedToCtorIsOk() throws Exception {
+ public void nullParameterValuesPassedToCtorIsOk() {
new MapSqlParameterSource(null);
}
@Test(expected = IllegalArgumentException.class)
- public void getValueChokesIfParameterIsNotPresent() throws Exception {
+ public void getValueChokesIfParameterIsNotPresent() {
MapSqlParameterSource source = new MapSqlParameterSource();
source.getValue("pechorin was right!");
}
@Test
- public void sqlParameterValueRegistersSqlType() throws Exception {
+ public void sqlParameterValueRegistersSqlType() {
MapSqlParameterSource msps = new MapSqlParameterSource("FOO", new SqlParameterValue(2, "Foo"));
assertEquals("Correct SQL Type not registered", 2, msps.getSqlType("FOO"));
MapSqlParameterSource msps2 = new MapSqlParameterSource();
diff --git a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java
index 9f50a3ca09..53d26232b3 100644
--- a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java
+++ b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -111,22 +111,25 @@ import org.springframework.util.xml.StaxUtils;
* @author Juergen Hoeller
* @author Rossen Stoyanchev
* @since 3.0
- * @see #setContextPath(String)
- * @see #setClassesToBeBound(Class[])
- * @see #setJaxbContextProperties(Map)
- * @see #setMarshallerProperties(Map)
- * @see #setUnmarshallerProperties(Map)
- * @see #setSchema(Resource)
- * @see #setSchemas(Resource[])
- * @see #setMarshallerListener(javax.xml.bind.Marshaller.Listener)
- * @see #setUnmarshallerListener(javax.xml.bind.Unmarshaller.Listener)
- * @see #setAdapters(XmlAdapter[])
+ * @see #setContextPath
+ * @see #setClassesToBeBound
+ * @see #setJaxbContextProperties
+ * @see #setMarshallerProperties
+ * @see #setUnmarshallerProperties
+ * @see #setSchema
+ * @see #setSchemas
+ * @see #setMarshallerListener
+ * @see #setUnmarshallerListener
+ * @see #setAdapters
*/
public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, GenericMarshaller, GenericUnmarshaller,
BeanClassLoaderAware, InitializingBean {
private static final String CID = "cid:";
+ private static final EntityResolver NO_OP_ENTITY_RESOLVER =
+ (publicId, systemId) -> new InputSource(new StringReader(""));
+
/** Logger available to subclasses */
protected final Log logger = LogFactory.getLog(getClass());
@@ -243,8 +246,8 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
* Set the packages to search for classes with JAXB2 annotations in the classpath.
* This is using a Spring-bases search and therefore analogous to Spring's component-scan
* feature ({@link org.springframework.context.annotation.ClassPathBeanDefinitionScanner}).
- *
Setting either this property, {@link #setContextPath "contextPath"}
- * or {@link #setClassesToBeBound "classesToBeBound"} is required.
+ *
Setting either this property, {@link #setContextPath "contextPath"} or
+ * {@link #setClassesToBeBound "classesToBeBound"} is required.
*/
public void setPackagesToScan(@Nullable String... packagesToScan) {
this.packagesToScan = packagesToScan;
@@ -267,8 +270,9 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
}
/**
- * Set the JAXB {@code Marshaller} properties. These properties will be set on the
- * underlying JAXB {@code Marshaller}, and allow for features such as indentation.
+ * Set the JAXB {@code Marshaller} properties.
+ *
These properties will be set on the underlying JAXB {@code Marshaller},
+ * and allow for features such as indentation.
* @param properties the properties
* @see javax.xml.bind.Marshaller#setProperty(String, Object)
* @see javax.xml.bind.Marshaller#JAXB_ENCODING
@@ -281,8 +285,8 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
}
/**
- * Set the JAXB {@code Unmarshaller} properties. These properties will be set on the
- * underlying JAXB {@code Unmarshaller}.
+ * Set the JAXB {@code Unmarshaller} properties.
+ *
These properties will be set on the underlying JAXB {@code Unmarshaller}.
* @param properties the properties
* @see javax.xml.bind.Unmarshaller#setProperty(String, Object)
*/
@@ -314,7 +318,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
/**
* Specify the {@code XmlAdapter}s to be registered with the JAXB {@code Marshaller}
- * and {@code Unmarshaller}
+ * and {@code Unmarshaller}.
*/
public void setAdapters(XmlAdapter, ?>... adapters) {
this.adapters = adapters;
@@ -335,7 +339,8 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
}
/**
- * Set the schema language. Default is the W3C XML Schema: {@code http://www.w3.org/2001/XMLSchema"}.
+ * Set the schema language.
+ * Default is the W3C XML Schema: {@code http://www.w3.org/2001/XMLSchema"}.
* @see XMLConstants#W3C_XML_SCHEMA_NS_URI
* @see XMLConstants#RELAXNG_NS_URI
*/
@@ -346,8 +351,8 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
/**
* Set the resource resolver, as used to load the schema resources.
* @see SchemaFactory#setResourceResolver(org.w3c.dom.ls.LSResourceResolver)
- * @see #setSchema(Resource)
- * @see #setSchemas(Resource[])
+ * @see #setSchema
+ * @see #setSchemas
*/
public void setSchemaResourceResolver(LSResourceResolver schemaResourceResolver) {
this.schemaResourceResolver = schemaResourceResolver;
@@ -371,10 +376,11 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
}
/**
- * Specify whether the {@link #supports(Class)} returns {@code true} for the {@link JAXBElement} class.
- *
Default is {@code false}, meaning that {@code supports(Class)} always returns {@code false} for
- * {@code JAXBElement} classes (though {@link #supports(Type)} can return {@code true}, since it can
- * obtain the type parameters of {@code JAXBElement}).
+ * Specify whether the {@link #supports(Class)} returns {@code true} for the
+ * {@link JAXBElement} class.
+ *
Default is {@code false}, meaning that {@code supports(Class)} always returns
+ * {@code false} for {@code JAXBElement} classes (though {@link #supports(Type)} can
+ * return {@code true}, since it can obtain the type parameters of {@code JAXBElement}).
*
This property is typically enabled in combination with usage of classes like
* {@link org.springframework.web.servlet.view.xml.MarshallingView MarshallingView},
* since the {@code ModelAndView} does not offer type parameter information at runtime.
@@ -430,8 +436,8 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
* {@code Source} passed to {@link #unmarshal(Source)} is a {@link SAXSource} or
* {@link StreamSource}. It has no effect for {@link DOMSource} or {@link StAXSource}
* instances.
- *
Note: setting this option to {@code true} also
- * automatically sets {@link #setSupportDtd} to {@code true}.
+ *
Note: setting this option to {@code true} also automatically
+ * sets {@link #setSupportDtd} to {@code true}.
*/
public void setProcessExternalEntities(boolean processExternalEntities) {
this.processExternalEntities = processExternalEntities;
@@ -707,6 +713,21 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
}
}
+ /**
+ * Return a newly created JAXB marshaller.
+ *
Note: JAXB marshallers are not necessarily thread-safe.
+ */
+ protected Marshaller createMarshaller() {
+ try {
+ Marshaller marshaller = getJaxbContext().createMarshaller();
+ initJaxbMarshaller(marshaller);
+ return marshaller;
+ }
+ catch (JAXBException ex) {
+ throw convertJaxbException(ex);
+ }
+ }
+
private void marshalStaxResult(Marshaller jaxbMarshaller, Object graph, Result staxResult) throws JAXBException {
XMLStreamWriter streamWriter = StaxUtils.getXMLStreamWriter(staxResult);
if (streamWriter != null) {
@@ -724,26 +745,14 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
}
/**
- * Return a newly created JAXB marshaller. JAXB marshallers are not necessarily thread safe.
- */
- protected Marshaller createMarshaller() {
- try {
- Marshaller marshaller = getJaxbContext().createMarshaller();
- initJaxbMarshaller(marshaller);
- return marshaller;
- }
- catch (JAXBException ex) {
- throw convertJaxbException(ex);
- }
- }
-
- /**
- * Template method that can be overridden by concrete JAXB marshallers for custom initialization behavior.
- * Gets called after creation of JAXB {@code Marshaller}, and after the respective properties have been set.
- *
The default implementation sets the {@link #setMarshallerProperties(Map) defined properties}, the {@link
- * #setValidationEventHandler(ValidationEventHandler) validation event handler}, the {@link #setSchemas(Resource[])
- * schemas}, {@link #setMarshallerListener(javax.xml.bind.Marshaller.Listener) listener}, and
- * {@link #setAdapters(XmlAdapter[]) adapters}.
+ * Template method that can be overridden by concrete JAXB marshallers
+ * for custom initialization behavior. Gets called after creation of JAXB
+ * {@code Marshaller}, and after the respective properties have been set.
+ *
The default implementation sets the
+ * {@link #setMarshallerProperties defined properties}, the
+ * {@link #setValidationEventHandler validation event handler}, the
+ * {@link #setSchemas schemas}, {@link #setMarshallerListener listener},
+ * and {@link #setAdapters adapters}.
*/
protected void initJaxbMarshaller(Marshaller marshaller) throws JAXBException {
if (this.marshallerProperties != null) {
@@ -806,6 +815,21 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
}
}
+ /**
+ * Return a newly created JAXB unmarshaller.
+ *
Note: JAXB unmarshallers are not necessarily thread-safe.
+ */
+ protected Unmarshaller createUnmarshaller() {
+ try {
+ Unmarshaller unmarshaller = getJaxbContext().createUnmarshaller();
+ initJaxbUnmarshaller(unmarshaller);
+ return unmarshaller;
+ }
+ catch (JAXBException ex) {
+ throw convertJaxbException(ex);
+ }
+ }
+
protected Object unmarshalStaxSource(Unmarshaller jaxbUnmarshaller, Source staxSource) throws JAXBException {
XMLStreamReader streamReader = StaxUtils.getXMLStreamReader(staxSource);
if (streamReader != null) {
@@ -872,27 +896,14 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
}
/**
- * Return a newly created JAXB unmarshaller.
- * Note: JAXB unmarshallers are not necessarily thread-safe.
- */
- protected Unmarshaller createUnmarshaller() {
- try {
- Unmarshaller unmarshaller = getJaxbContext().createUnmarshaller();
- initJaxbUnmarshaller(unmarshaller);
- return unmarshaller;
- }
- catch (JAXBException ex) {
- throw convertJaxbException(ex);
- }
- }
-
- /**
- * Template method that can be overridden by concrete JAXB marshallers for custom initialization behavior.
- * Gets called after creation of JAXB {@code Marshaller}, and after the respective properties have been set.
- *
The default implementation sets the {@link #setUnmarshallerProperties(Map) defined properties}, the {@link
- * #setValidationEventHandler(ValidationEventHandler) validation event handler}, the {@link #setSchemas(Resource[])
- * schemas}, {@link #setUnmarshallerListener(javax.xml.bind.Unmarshaller.Listener) listener}, and
- * {@link #setAdapters(XmlAdapter[]) adapters}.
+ * Template method that can be overridden by concrete JAXB marshallers
+ * for custom initialization behavior. Gets called after creation of JAXB
+ * {@code Marshaller}, and after the respective properties have been set.
+ *
The default implementation sets the
+ * {@link #setUnmarshallerProperties defined properties}, the
+ * {@link #setValidationEventHandler validation event handler}, the
+ * {@link #setSchemas schemas}, {@link #setUnmarshallerListener listener},
+ * and {@link #setAdapters adapters}.
*/
protected void initJaxbUnmarshaller(Unmarshaller unmarshaller) throws JAXBException {
if (this.unmarshallerProperties != null) {
@@ -917,8 +928,8 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
}
/**
- * Convert the given {@code JAXBException} to an appropriate exception from the
- * {@code org.springframework.oxm} hierarchy.
+ * Convert the given {@code JAXBException} to an appropriate exception
+ * from the {@code org.springframework.oxm} hierarchy.
* @param ex {@code JAXBException} that occurred
* @return the corresponding {@code XmlMappingException}
*/
@@ -1079,8 +1090,4 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
}
}
-
- private static final EntityResolver NO_OP_ENTITY_RESOLVER =
- (publicId, systemId) -> new InputSource(new StringReader(""));
-
}
diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java
index c3d35d4b55..33f2ca1e94 100644
--- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java
+++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java
@@ -60,6 +60,8 @@ import org.springframework.util.StringUtils;
*
{@link #set(String, String)} sets the header value to a single string value
*
*
+ * Note that {@code HttpHeaders} generally treats header names in a case-insensitive manner.
+ *
* @author Arjen Poutsma
* @author Sebastien Deleuze
* @author Brian Clozel
diff --git a/spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java b/spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java
index 3b885f39bb..0b86523081 100644
--- a/spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java
+++ b/spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -52,14 +52,14 @@ public class CorsConfiguration {
/** Wildcard representing all origins, methods, or headers. */
public static final String ALL = "*";
- private static final List DEFAULT_METHODS =
- Collections.unmodifiableList(Arrays.asList(HttpMethod.GET, HttpMethod.HEAD));
+ private static final List DEFAULT_METHODS = Collections.unmodifiableList(
+ Arrays.asList(HttpMethod.GET, HttpMethod.HEAD));
- private static final List DEFAULT_PERMIT_ALL =
- Collections.unmodifiableList(Arrays.asList(ALL));
+ private static final List DEFAULT_PERMIT_METHODS = Collections.unmodifiableList(
+ Arrays.asList(HttpMethod.GET.name(), HttpMethod.HEAD.name(), HttpMethod.POST.name()));
- private static final List DEFAULT_PERMIT_METHODS =
- Collections.unmodifiableList(Arrays.asList(HttpMethod.GET.name(), HttpMethod.HEAD.name(), HttpMethod.POST.name()));
+ private static final List DEFAULT_PERMIT_ALL = Collections.unmodifiableList(
+ Collections.singletonList(ALL));
@Nullable
@@ -322,22 +322,21 @@ public class CorsConfiguration {
return this.maxAge;
}
+
/**
* By default a newly created {@code CorsConfiguration} does not permit any
* cross-origin requests and must be configured explicitly to indicate what
* should be allowed.
- *
* Use this method to flip the initialization model to start with open
* defaults that permit all cross-origin requests for GET, HEAD, and POST
* requests. Note however that this method will not override any existing
* values already set.
- *
*
The following defaults are applied if not already set:
*
- * - Allow all origins.
- * - Allow "simple" methods {@code GET}, {@code HEAD} and {@code POST}.
- * - Allow all headers.
- * - Set max age to 1800 seconds (30 minutes).
+ * - Allow all origins.
+ * - Allow "simple" methods {@code GET}, {@code HEAD} and {@code POST}.
+ * - Allow all headers.
+ * - Set max age to 1800 seconds (30 minutes).
*
*/
public CorsConfiguration applyPermitDefaultValues() {
@@ -361,23 +360,19 @@ public class CorsConfiguration {
/**
* Combine the non-null properties of the supplied
* {@code CorsConfiguration} with this one.
- *
* When combining single values like {@code allowCredentials} or
* {@code maxAge}, {@code this} properties are overridden by non-null
* {@code other} properties if any.
- *
*
Combining lists like {@code allowedOrigins}, {@code allowedMethods},
* {@code allowedHeaders} or {@code exposedHeaders} is done in an additive
* way. For example, combining {@code ["GET", "POST"]} with
* {@code ["PATCH"]} results in {@code ["GET", "POST", "PATCH"]}, but keep
* in mind that combining {@code ["GET", "POST"]} with {@code ["*"]}
* results in {@code ["*"]}.
- *
*
Notice that default permit values set by
* {@link CorsConfiguration#applyPermitDefaultValues()} are overridden by
* any value explicitly defined.
- *
- * @return the combined {@code CorsConfiguration} or {@code this}
+ * @return the combined {@code CorsConfiguration}, or {@code this}
* configuration if the supplied configuration is {@code null}
*/
@Nullable
diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java
index d2fb559bef..008271169d 100644
--- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java
+++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java
@@ -140,16 +140,8 @@ import org.springframework.web.servlet.view.tiles3.TilesConfigurer;
import org.springframework.web.servlet.view.tiles3.TilesViewResolver;
import org.springframework.web.util.UrlPathHelper;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
/**
* Tests loading actual MVC namespace configuration.
@@ -176,7 +168,7 @@ public class MvcNamespaceTests {
@Before
- public void setUp() throws Exception {
+ public void setup() throws Exception {
TestMockServletContext servletContext = new TestMockServletContext();
appContext = new XmlWebApplicationContext();
appContext.setServletContext(servletContext);
@@ -347,6 +339,7 @@ public class MvcNamespaceTests {
}
@Test
+ @SuppressWarnings("unchecked")
public void testResources() throws Exception {
loadBeanDefinitions("mvc-config-resources.xml");