diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java b/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java index f539e701807..9ec35a7e631 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 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. @@ -56,7 +56,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException { public UnsatisfiedDependencyException( String resourceDescription, String beanName, String propertyName, BeansException ex) { - this(resourceDescription, beanName, propertyName, (ex != null ? ": " + ex.getMessage() : "")); + this(resourceDescription, beanName, propertyName, (ex != null ? ex.getMessage() : "")); initCause(ex); } @@ -88,7 +88,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException { public UnsatisfiedDependencyException( String resourceDescription, String beanName, int ctorArgIndex, Class> ctorArgType, BeansException ex) { - this(resourceDescription, beanName, ctorArgIndex, ctorArgType, (ex != null ? ": " + ex.getMessage() : "")); + this(resourceDescription, beanName, ctorArgIndex, ctorArgType, (ex != null ? ex.getMessage() : "")); initCause(ex); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java index fd38f364ccd..88642eb493e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -196,6 +196,7 @@ public class DependencyDescriptor implements Serializable { * Optionally set the concrete class that contains this dependency. * This may differ from the class that declares the parameter/field in that * it may be a subclass thereof, potentially substituting type variables. + * @since 4.0 */ public void setContainingClass(Class> containingClass) { this.containingClass = containingClass; @@ -206,6 +207,7 @@ public class DependencyDescriptor implements Serializable { /** * Build a ResolvableType object for the wrapped parameter/field. + * @since 4.0 */ public ResolvableType getResolvableType() { return (this.field != null ? ResolvableType.forField(this.field, this.nestingLevel, this.containingClass) : @@ -217,6 +219,7 @@ public class DependencyDescriptor implements Serializable { *
This is {@code false} by default but may be overridden to return {@code true} in order
* to suggest to a {@link org.springframework.beans.factory.support.AutowireCandidateResolver}
* that a fallback match is acceptable as well.
+ * @since 4.0
*/
public boolean fallbackMatchAllowed() {
return false;
@@ -224,6 +227,7 @@ public class DependencyDescriptor implements Serializable {
/**
* Return a variant of this descriptor that is intended for a fallback match.
+ * @since 4.0
* @see #fallbackMatchAllowed()
*/
public DependencyDescriptor forFallbackMatch() {
diff --git a/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java b/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java
index 6ad47d7eb90..caad3982993 100644
--- a/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java
+++ b/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2016 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.
@@ -73,7 +73,8 @@ public class EnableMBeanExportConfigurationTests {
ObjectName oname = ObjectNameManager.getInstance("bean:name=testBean4");
assertNotNull(server.getObjectInstance(oname));
assertEquals("TEST", server.getAttribute(oname, "Name"));
- } finally {
+ }
+ finally {
ctx.close();
}
}
@@ -142,7 +143,8 @@ public class EnableMBeanExportConfigurationTests {
assertNotNull(server.getObjectInstance(oname));
String name = (String) server.getAttribute(oname, "Name");
assertNull(name);
- } finally {
+ }
+ finally {
ctx.close();
}
}
diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/EnumToStringConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/EnumToStringConverter.java
index bfd1762d969..02a5f19f29c 100644
--- a/spring-core/src/main/java/org/springframework/core/convert/support/EnumToStringConverter.java
+++ b/spring-core/src/main/java/org/springframework/core/convert/support/EnumToStringConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2016 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.
@@ -23,8 +23,9 @@ import org.springframework.core.convert.converter.Converter;
import org.springframework.util.ClassUtils;
/**
- * Calls {@link Enum#name()} to convert a source Enum to a String. This converter will
- * not match enums with interfaces that can be converterd.
+ * Calls {@link Enum#name()} to convert a source Enum to a String.
+ * This converter will not match enums with interfaces that can be converted.
+ *
* @author Keith Donald
* @author Phillip Webb
* @since 3.0
@@ -33,14 +34,16 @@ final class EnumToStringConverter implements Converter This may be because the request is not a multipart/form-data
- *
- * either because the part is not present in the request, or
- * because the web application is not configured correctly for processing
- * multipart requests -- e.g. no {@link MultipartResolver}.
+ * This may be because the request is not a multipart/form-data request,
+ * because the part is not present in the request, or because the web
+ * application is not configured correctly for processing multipart requests,
+ * e.g. no {@link MultipartResolver}.
*
* @author Rossen Stoyanchev
* @since 3.1
*/
+@SuppressWarnings("serial")
public class MissingServletRequestPartException extends ServletException {
- private static final long serialVersionUID = -1255077391966870705L;
-
private final String partName;
+
public MissingServletRequestPartException(String partName) {
- super("Required request part '" + partName + "' is not present.");
+ super("Required request part '" + partName + "' is not present");
this.partName = partName;
}
+
public String getRequestPartName() {
return this.partName;
}
+
}
diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequest.java b/spring-web/src/main/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequest.java
index b26637e632f..78eab9180e5 100644
--- a/spring-web/src/main/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequest.java
+++ b/spring-web/src/main/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 the original author or authors.
+ * Copyright 2002-2016 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,7 +33,6 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.util.WebUtils;
-
/**
* {@link ServerHttpRequest} implementation that accesses one part of a multipart
* request. If using {@link MultipartResolver} configuration the part is accessed
@@ -54,8 +53,8 @@ public class RequestPartServletServerHttpRequest extends ServletServerHttpReques
/**
- * Create a new instance.
- * @param request the current request
+ * Create a new {@code RequestPartServletServerHttpRequest} instance.
+ * @param request the current servlet request
* @param partName the name of the part to adapt to the {@link ServerHttpRequest} contract
* @throws MissingServletRequestPartException if the request part cannot be found
* @throws IllegalArgumentException if MultipartHttpServletRequest cannot be initialized
diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java
index 4617715a8ca..00b61b5f2b3 100644
--- a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java
+++ b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 the original author or authors.
+ * Copyright 2002-2016 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.
@@ -87,10 +87,10 @@ public class RequestParamMethodArgumentResolverTests {
private MockHttpServletRequest request;
+
@Before
public void setUp() throws Exception {
resolver = new RequestParamMethodArgumentResolver(null, true);
-
ParameterNameDiscoverer paramNameDiscoverer = new LocalVariableTableParameterNameDiscoverer();
Method method = getClass().getMethod("params", String.class, String[].class,
@@ -126,6 +126,7 @@ public class RequestParamMethodArgumentResolverTests {
webRequest = new ServletWebRequest(request, new MockHttpServletResponse());
}
+
@Test
public void supportsParameter() {
resolver = new RequestParamMethodArgumentResolver(null, true);
@@ -154,18 +155,16 @@ public class RequestParamMethodArgumentResolverTests {
request.addParameter("name", expected);
Object result = resolver.resolveArgument(paramNamedDefaultValueString, null, webRequest, null);
-
assertTrue(result instanceof String);
assertEquals("Invalid result", expected, result);
}
@Test
public void resolveStringArray() throws Exception {
- String[] expected = new String[]{"foo", "bar"};
+ String[] expected = new String[] {"foo", "bar"};
request.addParameter("name", expected);
Object result = resolver.resolveArgument(paramNamedStringArray, null, webRequest, null);
-
assertTrue(result instanceof String[]);
assertArrayEquals("Invalid result", expected, (String[]) result);
}
@@ -178,7 +177,6 @@ public class RequestParamMethodArgumentResolverTests {
webRequest = new ServletWebRequest(request);
Object result = resolver.resolveArgument(paramMultipartFile, null, webRequest, null);
-
assertTrue(result instanceof MultipartFile);
assertEquals("Invalid result", expected, result);
}
@@ -193,7 +191,6 @@ public class RequestParamMethodArgumentResolverTests {
webRequest = new ServletWebRequest(request);
Object result = resolver.resolveArgument(paramMultipartFileList, null, webRequest, null);
-
assertTrue(result instanceof List);
assertEquals(Arrays.asList(expected1, expected2), result);
}
@@ -208,9 +205,9 @@ public class RequestParamMethodArgumentResolverTests {
webRequest = new ServletWebRequest(request);
Object result = resolver.resolveArgument(paramMultipartFileArray, null, webRequest, null);
-
assertTrue(result instanceof MultipartFile[]);
MultipartFile[] parts = (MultipartFile[]) result;
+ assertEquals(2, parts.length);
assertEquals(parts[0], expected1);
assertEquals(parts[1], expected2);
}
@@ -242,7 +239,6 @@ public class RequestParamMethodArgumentResolverTests {
webRequest = new ServletWebRequest(request);
Object result = resolver.resolveArgument(paramPartList, null, webRequest, null);
-
assertTrue(result instanceof List);
assertEquals(Arrays.asList(expected1, expected2), result);
}
@@ -259,9 +255,9 @@ public class RequestParamMethodArgumentResolverTests {
webRequest = new ServletWebRequest(request);
Object result = resolver.resolveArgument(paramPartArray, null, webRequest, null);
-
assertTrue(result instanceof Part[]);
Part[] parts = (Part[]) result;
+ assertEquals(2, parts.length);
assertEquals(parts[0], expected1);
assertEquals(parts[1], expected2);
}
@@ -274,7 +270,6 @@ public class RequestParamMethodArgumentResolverTests {
webRequest = new ServletWebRequest(request);
Object result = resolver.resolveArgument(paramMultipartFileNotAnnot, null, webRequest, null);
-
assertTrue(result instanceof MultipartFile);
assertEquals("Invalid result", expected, result);
}
@@ -289,7 +284,6 @@ public class RequestParamMethodArgumentResolverTests {
webRequest = new ServletWebRequest(request);
Object result = resolver.resolveArgument(paramMultipartFileListNotAnnot, null, webRequest, null);
-
assertTrue(result instanceof List);
assertEquals(Arrays.asList(expected1, expected2), result);
}
@@ -300,9 +294,7 @@ public class RequestParamMethodArgumentResolverTests {
fail("Expected exception: request is not a multipart request");
}
- // SPR-9079
-
- @Test
+ @Test // SPR-9079
public void isMultipartRequestHttpPut() throws Exception {
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
MultipartFile expected = new MockMultipartFile("multipartFileList", "Hello World".getBytes());
@@ -311,7 +303,6 @@ public class RequestParamMethodArgumentResolverTests {
webRequest = new ServletWebRequest(request);
Object actual = resolver.resolveArgument(paramMultipartFileListNotAnnot, null, webRequest, null);
-
assertTrue(actual instanceof List);
assertEquals(expected, ((List>) actual).get(0));
}
@@ -334,7 +325,6 @@ public class RequestParamMethodArgumentResolverTests {
webRequest = new ServletWebRequest(request);
Object result = resolver.resolveArgument(paramPartNotAnnot, null, webRequest, null);
-
assertTrue(result instanceof Part);
assertEquals("Invalid result", expected, result);
}
@@ -342,7 +332,6 @@ public class RequestParamMethodArgumentResolverTests {
@Test
public void resolveDefaultValue() throws Exception {
Object result = resolver.resolveArgument(paramNamedDefaultValueString, null, webRequest, null);
-
assertTrue(result instanceof String);
assertEquals("Invalid result", "bar", result);
}
@@ -353,11 +342,8 @@ public class RequestParamMethodArgumentResolverTests {
fail("Expected exception");
}
- // SPR-10578
-
- @Test
+ @Test // SPR-10578
public void missingRequestParamEmptyValueConvertedToNull() throws Exception {
-
WebDataBinder binder = new WebRequestDataBinder(null);
binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
@@ -367,13 +353,11 @@ public class RequestParamMethodArgumentResolverTests {
this.request.addParameter("stringNotAnnot", "");
Object arg = resolver.resolveArgument(paramStringNotAnnot, null, webRequest, binderFactory);
-
assertNull(arg);
}
@Test
public void missingRequestParamEmptyValueNotRequired() throws Exception {
-
WebDataBinder binder = new WebRequestDataBinder(null);
binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
@@ -383,7 +367,6 @@ public class RequestParamMethodArgumentResolverTests {
this.request.addParameter("name", "");
Object arg = resolver.resolveArgument(paramNotRequired, null, webRequest, binderFactory);
-
assertNull(arg);
}
@@ -396,17 +379,13 @@ public class RequestParamMethodArgumentResolverTests {
assertEquals("plainValue", result);
}
- // SPR-8561
-
- @Test
+ @Test // SPR-8561
public void resolveSimpleTypeParamToNull() throws Exception {
Object result = resolver.resolveArgument(paramStringNotAnnot, null, webRequest, null);
assertNull(result);
}
- // SPR-10180
-
- @Test
+ @Test // SPR-10180
public void resolveEmptyValueToDefault() throws Exception {
this.request.addParameter("name", "");
Object result = resolver.resolveArgument(paramNamedDefaultValueString, null, webRequest, null);
@@ -429,13 +408,12 @@ public class RequestParamMethodArgumentResolverTests {
@Test
@SuppressWarnings("rawtypes")
- public void resolveOptional() throws Exception {
+ public void resolveOptionalParamValue() throws Exception {
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
initializer.setConversionService(new DefaultConversionService());
WebDataBinderFactory binderFactory = new DefaultDataBinderFactory(initializer);
Object result = resolver.resolveArgument(paramOptional, null, webRequest, binderFactory);
- assertEquals(Optional.class, result.getClass());
assertEquals(Optional.empty(), result);
this.request.addParameter("name", "123");
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java
index 99386e074ae..d84d1601f9d 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 the original author or authors.
+ * Copyright 2002-2016 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.
@@ -152,6 +152,28 @@ public abstract class AbstractHandlerMethodMapping This method may be invoked at runtime after initialization has completed.
+ * @param mapping the mapping for the handler method
+ * @param handler the handler
+ * @param method the method
+ */
+ public void registerMapping(T mapping, Object handler, Method method) {
+ this.mappingRegistry.register(mapping, handler, method);
+ }
+
+ /**
+ * Un-register the given mapping.
+ * This method may be invoked at runtime after initialization has completed.
+ * @param mapping the mapping to unregister
+ */
+ public void unregisterMapping(T mapping) {
+ this.mappingRegistry.unregister(mapping);
+ }
+
+
+ // Handler method detection
/**
* Detects handler methods at initialization.
@@ -195,13 +217,6 @@ public abstract class AbstractHandlerMethodMapping This method may be invoked at runtime after initialization has completed.
- * @param mapping the mapping for the handler method
- * @param handler the handler
- * @param method the method
- */
- public void registerMapping(T mapping, Object handler, Method method) {
- this.mappingRegistry.register(mapping, handler, method);
- }
- /**
- * Un-register the given mapping.
- * This method may be invoked at runtime after initialization has completed.
- * @param mapping the mapping to unregister
- */
- public void unregisterMapping(T mapping) {
- this.mappingRegistry.unregister(mapping);
- }
+ // Handler method lookup
/**
* Look up a handler method for the given request.
@@ -392,23 +375,6 @@ public abstract class AbstractHandlerMethodMapping An @{@link PathVariable} is a named value that gets resolved from a URI
- * template variable. It is always required and does not have a default value
- * to fall back on. See the base class
+ * An @{@link PathVariable} is a named value that gets resolved from a URI template variable.
+ * It is always required and does not have a default value to fall back on. See the base class
* {@link org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver}
* for more information on how named values are processed.
*
- * If the method parameter type is {@link Map}, the name specified in the
- * annotation is used to resolve the URI variable String value. The value is
- * then converted to a {@link Map} via type conversion assuming a suitable
- * {@link Converter} or {@link PropertyEditor} has been registered.
- * Or if the annotation does not specify name the
- * {@link RequestParamMapMethodArgumentResolver} is used instead to provide
- * access to all URI variables in a map.
+ * If the method parameter type is {@link Map}, the name specified in the annotation is used
+ * to resolve the URI variable String value. The value is then converted to a {@link Map} via
+ * type conversion, assuming a suitable {@link Converter} or {@link PropertyEditor} has been
+ * registered.
*
- * A {@link WebDataBinder} is invoked to apply type conversion to resolved
- * path variable values that don't yet match the method parameter type.
+ * A {@link WebDataBinder} is invoked to apply type conversion to resolved path variable
+ * values that don't yet match the method parameter type.
*
* @author Rossen Stoyanchev
* @author Arjen Poutsma
@@ -95,10 +90,9 @@ public class PathVariableMethodArgumentResolver extends AbstractNamedValueMethod
@Override
@SuppressWarnings("unchecked")
protected Object resolveName(String name, MethodParameter parameter, NativeWebRequest request) throws Exception {
- Map