Author: mgrigorov
Date: Sat Sep 25 16:11:36 2010
New Revision: 1001247

URL: http://svn.apache.org/viewvc?rev=1001247&view=rev
Log:
WICKET-3078 FileUploadException is masked behind WicketRuntimeException and not 
handled by a Form

Clean the handling of FileUploadException when creating 
MultipartServletWebRequest. Do not wrap it in WicketRuntimeException and then 
check the cause


Modified:
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java?rev=1001247&r1=1001246&r2=1001247&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java 
(original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java 
Sat Sep 25 16:11:36 2010
@@ -1358,21 +1358,14 @@ public class Form<T> extends WebMarkupCo
                                // TODO: Can't this be detected from header?
                                
getRequestCycle().setRequest(multipartWebRequest);
                        }
-                       catch (WicketRuntimeException wre)
+                       catch (final FileUploadException fux)
                        {
-                               if (wre.getCause() == null || !(wre.getCause() 
instanceof FileUploadException))
-                               {
-                                       throw wre;
-                               }
-
-                               FileUploadException e = 
(FileUploadException)wre.getCause();
-
                                // Create model with exception and maximum size 
values
                                final Map<String, Object> model = new 
HashMap<String, Object>();
-                               model.put("exception", e);
+                               model.put("exception", fux);
                                model.put("maxSize", getMaxSize());
 
-                               onFileUploadException(e, model);
+                               onFileUploadException(fux, model);
 
                                // don't process the form if there is a 
FileUploadException
                                return false;

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java?rev=1001247&r1=1001246&r2=1001247&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
 Sat Sep 25 16:11:36 2010
@@ -332,6 +332,7 @@ public class ServletWebRequest extends W
         * @throws FileUploadException
         */
        public MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize)
+               throws FileUploadException
        {
                return new 
MultipartServletWebRequestImpl(getHttpServletRequest(), filterPrefix, maxSize);
        }


Reply via email to