- Modify the code so that it doesn't log client disconnects unless debug is on, and...
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 19 Dec 2006 01:44:02 +0000 (01:44 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 19 Dec 2006 01:44:02 +0000 (01:44 +0000)
  runtime exceptions more transparent.
- Also, if failing to read or parse parameters doesn't throw an ISE, then a post too large shouldn't be an ISE. Or the
  opposite should be done, but IMO this would be excessive logging.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@488498 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/connector/Request.java

index b6bedd4..11706f4 100644 (file)
@@ -2426,27 +2426,31 @@ public class Request
         if (len > 0) {
             int maxPostSize = connector.getMaxPostSize();
             if ((maxPostSize > 0) && (len > maxPostSize)) {
-                context.getLogger().info
-                    (sm.getString("coyoteRequest.postTooLarge"));
-                throw new IllegalStateException("Post too large");
+                if (context.getLogger().isDebugEnabled()) {
+                    context.getLogger().debug("Post too large");
+                }
+                return;
+            }
+            byte[] formData = null;
+            if (len < CACHED_POST_LEN) {
+                if (postData == null)
+                    postData = new byte[CACHED_POST_LEN];
+                formData = postData;
+            } else {
+                formData = new byte[len];
             }
             try {
-                byte[] formData = null;
-                if (len < CACHED_POST_LEN) {
-                    if (postData == null)
-                        postData = new byte[CACHED_POST_LEN];
-                    formData = postData;
-                } else {
-                    formData = new byte[len];
+                if (readPostBody(formData, len) != len) {
+                    return;
                 }
-                int actualLen = readPostBody(formData, len);
-                if (actualLen == len) {
-                    parameters.processParameters(formData, 0, len);
+            } catch (IOException e) {
+                // Client disconnect
+                if (context.getLogger().isDebugEnabled()) {
+                    context.getLogger().debug(
+                            sm.getString("coyoteRequest.parseParameters"), e);
                 }
-            } catch (Throwable t) {
-                context.getLogger().warn(
-                        sm.getString("coyoteRequest.parseParameters"), t);
             }
+            parameters.processParameters(formData, 0, len);
         }
 
     }