From 1e42464c223d3c17ef4823faec416ff8d6db3030 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 17 Jun 2015 15:50:19 +0200 Subject: [PATCH] Polishing --- .../AsyncExecutionAspectSupport.java | 4 +- .../ExecutorBeanDefinitionParserTests.java | 11 +++-- .../BeanFactoryTransactionTests.java | 29 ++++++++++--- .../async/NoSupportAsyncWebRequest.java | 3 +- .../async/StandardServletAsyncWebRequest.java | 13 +++--- .../context/request/async/WebAsyncUtils.java | 22 +++++----- .../web/multipart/MultipartFile.java | 5 ++- .../web/multipart/MultipartResolver.java | 43 ++++++++----------- .../commons/CommonsFileUploadSupport.java | 4 +- .../commons/CommonsMultipartFile.java | 14 +++--- .../commons/CommonsMultipartResolver.java | 6 +-- .../web/multipart/commons/package-info.java | 6 +-- .../springframework/web/util/WebUtils.java | 13 +++--- 13 files changed, 95 insertions(+), 78 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java index eff63690b0..4b8389f8b6 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -31,7 +31,7 @@ import org.springframework.util.StringUtils; /** * Base class for asynchronous method execution aspects, such as - * {@link org.springframework.scheduling.annotation.AnnotationAsyncExecutionInterceptor} + * {@code org.springframework.scheduling.annotation.AnnotationAsyncExecutionInterceptor} * or {@code org.springframework.scheduling.aspectj.AnnotationAsyncExecutionAspect}. * *

Provides support for executor qualification on a method-by-method basis. diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java index 74e3d76639..9777e559e1 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -20,7 +20,6 @@ import java.util.concurrent.Callable; import java.util.concurrent.Executor; import java.util.concurrent.FutureTask; -import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; @@ -32,6 +31,8 @@ import org.springframework.core.task.TaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.util.CustomizableThreadCreator; +import static org.junit.Assert.*; + /** * @author Mark Fisher * @author Juergen Hoeller @@ -47,21 +48,23 @@ public class ExecutorBeanDefinitionParserTests { "executorContext.xml", ExecutorBeanDefinitionParserTests.class); } + @Test public void defaultExecutor() throws Exception { - Object executor = this.context.getBean("default"); + ThreadPoolTaskExecutor executor = this.context.getBean("default", ThreadPoolTaskExecutor.class); assertEquals(1, getCorePoolSize(executor)); assertEquals(Integer.MAX_VALUE, getMaxPoolSize(executor)); assertEquals(Integer.MAX_VALUE, getQueueCapacity(executor)); assertEquals(60, getKeepAliveSeconds(executor)); assertEquals(false, getAllowCoreThreadTimeOut(executor)); + FutureTask task = new FutureTask(new Callable() { @Override public String call() throws Exception { return "foo"; } }); - ((ThreadPoolTaskExecutor)executor).execute(task); + executor.execute(task); assertEquals("foo", task.get()); } diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java index 268cee7bb7..84fc439bdf 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 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. @@ -20,10 +20,11 @@ import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Map; -import junit.framework.TestCase; - import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; +import org.junit.Before; +import org.junit.Test; + import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.StaticMethodMatcherPointcut; import org.springframework.aop.target.HotSwappableTargetSource; @@ -40,31 +41,38 @@ import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionException; import org.springframework.transaction.TransactionStatus; +import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; + /** * Test cases for AOP transaction management. * * @author Rod Johnson + * @author Juergen Hoeller * @since 23.04.2003 */ -public class BeanFactoryTransactionTests extends TestCase { +public class BeanFactoryTransactionTests { private DefaultListableBeanFactory factory; - @Override + + @Before public void setUp() { this.factory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(this.factory).loadBeanDefinitions( new ClassPathResource("transactionalBeanFactory.xml", getClass())); } + + @Test public void testGetsAreNotTransactionalWithProxyFactory1() throws NoSuchMethodException { ITestBean testBean = (ITestBean) factory.getBean("proxyFactory1"); assertTrue("testBean is a dynamic proxy", Proxy.isProxyClass(testBean.getClass())); doTestGetsAreNotTransactional(testBean); } + @Test public void testGetsAreNotTransactionalWithProxyFactory2DynamicProxy() throws NoSuchMethodException { this.factory.preInstantiateSingletons(); ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2DynamicProxy"); @@ -72,12 +80,14 @@ public class BeanFactoryTransactionTests extends TestCase { doTestGetsAreNotTransactional(testBean); } + @Test public void testGetsAreNotTransactionalWithProxyFactory2Cglib() throws NoSuchMethodException { ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2Cglib"); assertTrue("testBean is CGLIB advised", AopUtils.isCglibProxy(testBean)); doTestGetsAreNotTransactional(testBean); } + @Test public void testProxyFactory2Lazy() throws NoSuchMethodException { ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2Lazy"); assertFalse(factory.containsSingleton("target")); @@ -85,6 +95,7 @@ public class BeanFactoryTransactionTests extends TestCase { assertTrue(factory.containsSingleton("target")); } + @Test public void testCglibTransactionProxyImplementsNoInterfaces() throws NoSuchMethodException { ImplementsNoInterfaces ini = (ImplementsNoInterfaces) factory.getBean("cglibNoInterfaces"); assertTrue("testBean is CGLIB advised", AopUtils.isCglibProxy(ini)); @@ -99,6 +110,7 @@ public class BeanFactoryTransactionTests extends TestCase { assertEquals(2, ptm.commits); } + @Test public void testGetsAreNotTransactionalWithProxyFactory3() throws NoSuchMethodException { ITestBean testBean = (ITestBean) factory.getBean("proxyFactory3"); assertTrue("testBean is a full proxy", testBean instanceof DerivedTestBean); @@ -158,14 +170,16 @@ public class BeanFactoryTransactionTests extends TestCase { assertTrue(testBean.getAge() == age); } + @Test public void testGetBeansOfTypeWithAbstract() { - Map beansOfType = factory.getBeansOfType(ITestBean.class, true, true); + Map beansOfType = factory.getBeansOfType(ITestBean.class, true, true); assertNotNull(beansOfType); } /** * Check that we fail gracefully if the user doesn't set any transaction attributes. */ + @Test public void testNoTransactionAttributeSource() { try { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); @@ -181,6 +195,7 @@ public class BeanFactoryTransactionTests extends TestCase { /** * Test that we can set the target to a dynamic TargetSource. */ + @Test public void testDynamicTargetSource() throws NoSuchMethodException { // Install facade CallCountingTransactionManager txMan = new CallCountingTransactionManager(); @@ -211,7 +226,7 @@ public class BeanFactoryTransactionTests extends TestCase { int counter = 0; @Override - public boolean matches(Method method, Class clazz) { + public boolean matches(Method method, Class clazz) { counter++; return true; } diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/NoSupportAsyncWebRequest.java b/spring-web/src/main/java/org/springframework/web/context/request/async/NoSupportAsyncWebRequest.java index 6158a82931..626e2a9135 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/NoSupportAsyncWebRequest.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/NoSupportAsyncWebRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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,6 +49,7 @@ public class NoSupportAsyncWebRequest extends ServletWebRequest implements Async return false; } + // Not supported public void startAsync() { diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java b/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java index 8e5e6d4d6b..6080a81e34 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -20,7 +20,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; - import javax.servlet.AsyncContext; import javax.servlet.AsyncEvent; import javax.servlet.AsyncListener; @@ -36,7 +35,7 @@ import org.springframework.web.context.request.ServletWebRequest; *

The servlet and all filters involved in an async request must have async * support enabled using the Servlet API or by adding an * {@code true} element to servlet and filter - * declarations in web.xml + * declarations in {@code web.xml}. * * @author Rossen Stoyanchev * @since 3.2 @@ -63,9 +62,9 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements super(request, response); } + /** - * {@inheritDoc} - *

In Servlet 3 async processing, the timeout period begins after the + * In Servlet 3 async processing, the timeout period begins after the * container processing thread has exited. */ public void setTimeout(Long timeout) { @@ -82,7 +81,7 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements } public boolean isAsyncStarted() { - return ((this.asyncContext != null) && getRequest().isAsyncStarted()); + return (this.asyncContext != null && getRequest().isAsyncStarted()); } /** @@ -101,6 +100,7 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements "or by adding \"true\" to servlet and " + "filter declarations in web.xml."); Assert.state(!isAsyncComplete(), "Async processing has already completed"); + if (isAsyncStarted()) { return; } @@ -116,6 +116,7 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements this.asyncContext.dispatch(); } + // --------------------------------------------------------------------- // Implementation of AsyncListener methods // --------------------------------------------------------------------- diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncUtils.java b/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncUtils.java index 86d47850db..ec83b84120 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncUtils.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.context.request.async; import java.lang.reflect.Constructor; @@ -67,18 +68,17 @@ public abstract class WebAsyncUtils { } /** - * Create an AsyncWebRequest instance. By default an instance of - * {@link StandardServletAsyncWebRequest} is created if running in Servlet - * 3.0 (or higher) environment or as a fallback, an instance of - * {@link NoSupportAsyncWebRequest} is returned. - * + * Create an AsyncWebRequest instance. By default, an instance of + * {@link StandardServletAsyncWebRequest} gets created when running in + * Servlet 3.0 (or higher) environment - as a fallback, an instance + * of {@link NoSupportAsyncWebRequest} will be returned. * @param request the current request * @param response the current response - * @return an AsyncWebRequest instance, never {@code null} + * @return an AsyncWebRequest instance (never {@code null}) */ public static AsyncWebRequest createAsyncWebRequest(HttpServletRequest request, HttpServletResponse response) { - return ClassUtils.hasMethod(ServletRequest.class, "startAsync") ? - createStandardServletAsyncWebRequest(request, response) : new NoSupportAsyncWebRequest(request, response); + return (ClassUtils.hasMethod(ServletRequest.class, "startAsync") ? + createStandardServletAsyncWebRequest(request, response) : new NoSupportAsyncWebRequest(request, response)); } private static AsyncWebRequest createStandardServletAsyncWebRequest(HttpServletRequest request, HttpServletResponse response) { @@ -90,8 +90,8 @@ public abstract class WebAsyncUtils { } return (AsyncWebRequest) BeanUtils.instantiateClass(standardAsyncRequestConstructor, request, response); } - catch (Throwable t) { - throw new IllegalStateException("Failed to instantiate StandardServletAsyncWebRequest", t); + catch (Throwable ex) { + throw new IllegalStateException("Failed to instantiate StandardServletAsyncWebRequest", ex); } } diff --git a/spring-web/src/main/java/org/springframework/web/multipart/MultipartFile.java b/spring-web/src/main/java/org/springframework/web/multipart/MultipartFile.java index 86f73591a4..4d4a04503e 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/MultipartFile.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/MultipartFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -94,6 +94,9 @@ public interface MultipartFile { *

If the file has been moved in the filesystem, this operation cannot * be invoked again. Therefore, call this method just once to be able to * work with any storage mechanism. + *

Note: when using Servlet 3.0 multipart support you + * need to configure the location relative to which files will be copied + * as explained in {@link javax.servlet.http.Part#write}. * @param dest the destination file * @throws IOException in case of reading or writing errors * @throws IllegalStateException if the file has already been moved diff --git a/spring-web/src/main/java/org/springframework/web/multipart/MultipartResolver.java b/spring-web/src/main/java/org/springframework/web/multipart/MultipartResolver.java index 3fd05f9151..79898d9646 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/MultipartResolver.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/MultipartResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -26,8 +26,10 @@ import javax.servlet.http.HttpServletRequest; * *

There are two concrete implementations included in Spring, as of Spring 3.1: *

* *

There is no default resolver implementation used for Spring @@ -38,14 +40,11 @@ import javax.servlet.http.HttpServletRequest; * application context. Such a resolver gets applied to all requests handled * by that {@link org.springframework.web.servlet.DispatcherServlet}. * - *

If a {@link org.springframework.web.servlet.DispatcherServlet} detects - * a multipart request, it will resolve it via the configured - * {@link MultipartResolver} and pass on a - * wrapped {@link javax.servlet.http.HttpServletRequest}. - * Controllers can then cast their given request to the - * {@link MultipartHttpServletRequest} - * interface, which permits access to any - * {@link MultipartFile MultipartFiles}. + *

If a {@link org.springframework.web.servlet.DispatcherServlet} detects a + * multipart request, it will resolve it via the configured {@link MultipartResolver} + * and pass on a wrapped {@link javax.servlet.http.HttpServletRequest}. Controllers + * can then cast their given request to the {@link MultipartHttpServletRequest} + * interface, which allows for access to any {@link MultipartFile MultipartFiles}. * Note that this cast is only supported in case of an actual multipart request. * *

@@ -58,23 +57,19 @@ import javax.servlet.http.HttpServletRequest;
  * Instead of direct access, command or form controllers can register a
  * {@link org.springframework.web.multipart.support.ByteArrayMultipartFileEditor}
  * or {@link org.springframework.web.multipart.support.StringMultipartFileEditor}
- * with their data binder, to automatically apply multipart content to command
+ * with their data binder, to automatically apply multipart content to form
  * bean properties.
  *
- * 

As an alternative to using a - * {@link MultipartResolver} with a + *

As an alternative to using a {@link MultipartResolver} with a * {@link org.springframework.web.servlet.DispatcherServlet}, * a {@link org.springframework.web.multipart.support.MultipartFilter} can be * registered in {@code web.xml}. It will delegate to a corresponding - * {@link MultipartResolver} bean in the root - * application context. This is mainly intended for applications that do not - * use Spring's own web MVC framework. + * {@link MultipartResolver} bean in the root application context. This is mainly + * intended for applications that do not use Spring's own web MVC framework. * - *

Note: There is hardly ever a need to access the - * {@link MultipartResolver} itself - * from application code. It will simply do its work behind the scenes, - * making - * {@link MultipartHttpServletRequest MultipartHttpServletRequests} + *

Note: There is hardly ever a need to access the {@link MultipartResolver} + * itself from application code. It will simply do its work behind the scenes, + * making {@link MultipartHttpServletRequest MultipartHttpServletRequests} * available to controllers. * * @author Juergen Hoeller @@ -101,8 +96,8 @@ public interface MultipartResolver { /** * Parse the given HTTP request into multipart files and parameters, * and wrap the request inside a - * {@link org.springframework.web.multipart.MultipartHttpServletRequest} object - * that provides access to file descriptors and makes contained + * {@link org.springframework.web.multipart.MultipartHttpServletRequest} + * object that provides access to file descriptors and makes contained * parameters accessible via the standard ServletRequest methods. * @param request the servlet request to wrap (must be of a multipart content type) * @return the wrapped servlet request diff --git a/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsFileUploadSupport.java b/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsFileUploadSupport.java index e05e110a7d..f6e6f6c6bc 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsFileUploadSupport.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsFileUploadSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -39,7 +39,7 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.util.WebUtils; /** - * Base class for multipart resolvers that use Jakarta Commons FileUpload + * Base class for multipart resolvers that use Apache Commons FileUpload * 1.2 or above. * *

Provides common configuration properties and parsing functionality diff --git a/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsMultipartFile.java b/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsMultipartFile.java index ae9ae6ecf1..ac9854deb3 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsMultipartFile.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsMultipartFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; + import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.disk.DiskFileItem; @@ -30,7 +31,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.web.multipart.MultipartFile; /** - * MultipartFile implementation for Jakarta Commons FileUpload. + * MultipartFile implementation for Apache Commons FileUpload. * * @author Trevor D. Cook * @author Juergen Hoeller @@ -56,6 +57,7 @@ public class CommonsMultipartFile implements MultipartFile, Serializable { this.size = this.fileItem.getSize(); } + /** * Return the underlying {@code org.apache.commons.fileupload.FileItem} * instance. There is hardly any need to access this. @@ -75,18 +77,18 @@ public class CommonsMultipartFile implements MultipartFile, Serializable { // Should never happen. return ""; } - // check for Unix-style path + // Check for Unix-style path int pos = filename.lastIndexOf("/"); if (pos == -1) { - // check for Windows-style path + // Check for Windows-style path pos = filename.lastIndexOf("\\"); } if (pos != -1) { - // any sort of path separator found + // Any sort of path separator found... return filename.substring(pos + 1); } else { - // plain name + // A plain name return filename; } } diff --git a/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsMultipartResolver.java b/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsMultipartResolver.java index 25f743befc..80f266ed26 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsMultipartResolver.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsMultipartResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -37,8 +37,8 @@ import org.springframework.web.multipart.support.DefaultMultipartHttpServletRequ import org.springframework.web.util.WebUtils; /** - * Servlet-based {@link org.springframework.web.multipart.MultipartResolver} implementation - * for Jakarta Commons FileUpload + * Servlet-based {@link MultipartResolver} implementation for + * Apache Commons FileUpload * 1.2 or above. * *

Provides "maxUploadSize", "maxInMemorySize" and "defaultEncoding" settings as diff --git a/spring-web/src/main/java/org/springframework/web/multipart/commons/package-info.java b/spring-web/src/main/java/org/springframework/web/multipart/commons/package-info.java index 931eaf305a..001283a1fe 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/commons/package-info.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/commons/package-info.java @@ -1,9 +1,5 @@ - /** - * * MultipartResolver implementation for - * Jakarta Commons FileUpload. - * + * Apache Commons FileUpload. */ package org.springframework.web.multipart.commons; - diff --git a/spring-web/src/main/java/org/springframework/web/util/WebUtils.java b/spring-web/src/main/java/org/springframework/web/util/WebUtils.java index 044cfb2922..b33c6ce6f1 100644 --- a/spring-web/src/main/java/org/springframework/web/util/WebUtils.java +++ b/spring-web/src/main/java/org/springframework/web/util/WebUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -174,7 +174,7 @@ public abstract class WebUtils { * i.e. the value of the "defaultHtmlEscape" context-param in {@code web.xml} * (if any). Falls back to {@code false} in case of no explicit default given. * @param servletContext the servlet context of the web application - * @return whether default HTML escaping is enabled (default is false) + * @return whether default HTML escaping is enabled (default is {@code false}) */ public static boolean isDefaultHtmlEscape(ServletContext servletContext) { if (servletContext == null) { @@ -192,14 +192,15 @@ public abstract class WebUtils { * an actual boolean value specified, allowing to have a context-specific * default in case of no setting at the global level. * @param servletContext the servlet context of the web application - * @return whether default HTML escaping is enabled (null = no explicit default) + * @return whether default HTML escaping is enabled for the given application + * ({@code null} = no explicit default) */ public static Boolean getDefaultHtmlEscape(ServletContext servletContext) { if (servletContext == null) { return null; } String param = servletContext.getInitParameter(HTML_ESCAPE_CONTEXT_PARAM); - return (StringUtils.hasText(param)? Boolean.valueOf(param) : null); + return (StringUtils.hasText(param) ? Boolean.valueOf(param) : null); } /** @@ -730,9 +731,9 @@ public abstract class WebUtils { * like this {@code "q1=a;q1=b;q2=a,b,c"}. The resulting map would contain * keys {@code "q1"} and {@code "q2"} with values {@code ["a","b"]} and * {@code ["a","b","c"]} respectively. - * * @param matrixVariables the unparsed matrix variables string - * @return a map with matrix variable names and values, never {@code null} + * @return a map with matrix variable names and values (never {@code null}) + * @since 3.2 */ public static MultiValueMap parseMatrixVariables(String matrixVariables) { MultiValueMap result = new LinkedMultiValueMap();