Author: ningjiang
Date: Wed Mar 30 07:42:33 2011
New Revision: 1086867

URL: http://svn.apache.org/viewvc?rev=1086867&view=rev
Log:
CAMEL-3816 Throw the exception when the post form is not right

Modified:
    
camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
    
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java

Modified: 
camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java?rev=1086867&r1=1086866&r2=1086867&view=diff
==============================================================================
--- 
camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
 (original)
+++ 
camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
 Wed Mar 30 07:42:33 2011
@@ -21,10 +21,10 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.Enumeration;
 import java.util.Map;
+
 import javax.activation.DataHandler;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
@@ -98,7 +98,7 @@ public class DefaultHttpBinding implemen
 
         try {
             populateRequestParameters(request, message);
-        } catch (UnsupportedEncodingException e) {
+        } catch (Exception e) {
             throw new RuntimeCamelException("Cannot read request parameters 
due " + e.getMessage(), e);
         }
         
@@ -132,7 +132,7 @@ public class DefaultHttpBinding implemen
         populateAttachments(request, message);
     }
     
-    protected void populateRequestParameters(HttpServletRequest request, 
HttpMessage message) throws UnsupportedEncodingException {
+    protected void populateRequestParameters(HttpServletRequest request, 
HttpMessage message) throws Exception {
         //we populate the http request parameters without checking the request 
method
         Map<String, Object> headers = message.getHeaders();
         Enumeration names = request.getParameterNames();
@@ -162,6 +162,8 @@ public class DefaultHttpBinding implemen
                         && 
!headerFilterStrategy.applyFilterToExternalHeaders(name, value, 
message.getExchange())) {
                         headers.put(name, value);
                     }
+                } else {
+                    throw new IllegalArgumentException("Cannot parser the 
parameter " + param);
                 }
             }
         }

Modified: 
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java?rev=1086867&r1=1086866&r2=1086867&view=diff
==============================================================================
--- 
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
 (original)
+++ 
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
 Wed Mar 30 07:42:33 2011
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.Enumeration;
 import java.util.Map;
@@ -70,7 +69,6 @@ public class DefaultHttpBinding implemen
         this.headerFilterStrategy = endpoint.getHeaderFilterStrategy();
     }
 
-    @SuppressWarnings("rawtypes")
     public void readRequest(HttpServletRequest request, HttpMessage message) {
         // lets force a parse of the body and headers
         message.getBody();
@@ -99,7 +97,7 @@ public class DefaultHttpBinding implemen
 
         try {
             populateRequestParameters(request, message);
-        } catch (UnsupportedEncodingException e) {
+        } catch (Exception e) {
             throw new RuntimeCamelException("Cannot read request parameters 
due " + e.getMessage(), e);
         }
 
@@ -133,8 +131,7 @@ public class DefaultHttpBinding implemen
         populateAttachments(request, message);
     }
 
-    @SuppressWarnings("rawtypes")
-    protected void populateRequestParameters(HttpServletRequest request, 
HttpMessage message) throws UnsupportedEncodingException {
+    protected void populateRequestParameters(HttpServletRequest request, 
HttpMessage message) throws Exception {
         //we populate the http request parameters without checking the request 
method
         Map<String, Object> headers = message.getHeaders();
         Enumeration names = request.getParameterNames();
@@ -163,12 +160,13 @@ public class DefaultHttpBinding implemen
                             && 
!headerFilterStrategy.applyFilterToExternalHeaders(name, value, 
message.getExchange())) {
                         headers.put(name, value);
                     }
+                } else {
+                    throw new IllegalArgumentException("Cannot parser the 
parameter " + param);
                 }
             }
         }
     }
 
-    @SuppressWarnings("rawtypes")
     protected void populateAttachments(HttpServletRequest request, HttpMessage 
message) {
         // check if there is multipart files, if so will put it into 
DataHandler
         Enumeration names = request.getAttributeNames();


Reply via email to