Author: jfclere
Date: Sun Apr 28 07:55:14 2013
New Revision: 1476728

URL: http://svn.apache.org/r1476728
Log:
commit accepted patch for BZ 52184.

Modified:
    tomcat/tc6.0.x/trunk/STATUS.txt
    
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/LocalStrings.properties
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
    tomcat/tc6.0.x/trunk/webapps/docs/config/systemprops.xml

Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1476728&r1=1476727&r2=1476728&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Sun Apr 28 07:55:14 2013
@@ -31,18 +31,6 @@ PATCHES ACCEPTED TO BACKPORT:
 PATCHES PROPOSED TO BACKPORT:
   [ New proposals should be added at the end of the list ]
 
-* Backport UserDataHelper class (issue 52184)
-  Provide greater control over the logging of errors triggered by invalid
-  input data (i.e. data over which Tomcat has no control).
-
-  Note: cookies logging (o.a.t.util.http.Cookies) does not need to be
-  addressed in Tomcat 6, because all logging in that class here is done at
-  debug level.
-
-  
http://people.apache.org/~kkolinko/patches/2013-03-24_tc6_52184_UserDataHelper.patch
-  +1: kkolinko, rjung, jfclere
-  -1:
-
 * For https://issues.apache.org/bugzilla/show_bug.cgi?id=52055
   Ensure that filters are recycled.
   Inspired by r1334790 (TC7), r565964 (TC6 Nio)

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/LocalStrings.properties?rev=1476728&r1=1476727&r2=1476728&view=diff
==============================================================================
--- 
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/LocalStrings.properties 
(original)
+++ 
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/LocalStrings.properties 
Sun Apr 28 07:55:14 2013
@@ -20,7 +20,9 @@ parameters.decodeFail.info=Character dec
 parameters.emptyChunk=Empty parameter chunk ignored
 parameters.invalidChunk=Invalid chunk starting at byte [{0}] and ending at 
byte [{1}] with a value of [{2}] ignored
 parameters.maxCountFail=More than the maximum number of request parameters 
(GET plus POST) for a single request ([{0}]) were detected. Any parameters 
beyond this limit have been ignored. To change this limit, set the 
maxParameterCount attribute on the Connector.
+parameters.maxCountFail.fallToDebug=\n Note: further occurrences of this error 
will be logged at DEBUG level.
 parameters.multipleDecodingFail=Character decoding failed. A total of [{0}] 
failures were detected but only the first was logged. Enable debug level 
logging for this logger to log all failures.
 parameters.noequal=Parameter starting at position [{0}] and ending at position 
[{1}] with a value of [{0}] was not followed by an '=' character
+parameters.fallToDebug=\n Note: further occurrences of Parameter errors will 
be logged at DEBUG level.
 
 headers.maxCountFail=More than the maximum allowed number of headers ([{0}]) 
were detected.

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java?rev=1476728&r1=1476727&r2=1476728&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java Sun 
Apr 28 07:55:14 2013
@@ -30,6 +30,7 @@ import org.apache.tomcat.util.buf.B2CCon
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.buf.UDecoder;
+import org.apache.tomcat.util.log.UserDataHelper;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -41,6 +42,10 @@ public final class Parameters {
     private static final org.apache.juli.logging.Log log =
         org.apache.juli.logging.LogFactory.getLog(Parameters.class );
 
+    private static final UserDataHelper userDataLog = new UserDataHelper(log);
+
+    private static final UserDataHelper maxParamCountLog = new 
UserDataHelper(log);
+
     protected static final StringManager sm =
         StringManager.getManager("org.apache.tomcat.util.http");
 
@@ -239,8 +244,22 @@ public final class Parameters {
 
             if (limit > -1 && parameterCount > limit) {
                 parseFailed = true;
-                log.info(sm.getString("parameters.maxCountFail",
-                        Integer.valueOf(limit)));
+                UserDataHelper.Mode logMode = maxParamCountLog.getNextMode();
+                if (logMode != null) {
+                    String message = sm.getString("parameters.maxCountFail",
+                            Integer.valueOf(limit));
+                    switch (logMode) {
+                        case INFO_THEN_DEBUG:
+                            message += sm.getString(
+                                    "parameters.maxCountFail.fallToDebug");
+                            //$FALL-THROUGH$
+                        case INFO:
+                            log.info(message);
+                            break;
+                        case DEBUG:
+                            log.debug(message);
+                    }
+                }
                 break;
             }
             int nameStart = pos;
@@ -323,9 +342,10 @@ public final class Parameters {
                     continue;
                 }
                 // &=foo&
-                if (log.isInfoEnabled()) {
-                    if (valueEnd >= nameStart && log.isDebugEnabled()) {
-                        String extract = null;
+                UserDataHelper.Mode logMode = userDataLog.getNextMode();
+                if (logMode != null) {
+                    String extract = null;
+                    if (valueEnd > nameStart) {
                         try {
                             extract = new String(bytes, nameStart,
                                     valueEnd - nameStart,
@@ -333,15 +353,21 @@ public final class Parameters {
                         } catch (UnsupportedEncodingException uee) {
                             // Not possible. All JVMs must support ISO-8859-1
                         }
-                        log.info(sm.getString("parameters.invalidChunk",
-                                Integer.valueOf(nameStart),
-                                Integer.valueOf(valueEnd),
-                                extract));
                     } else {
-                        log.info(sm.getString("parameters.invalidChunk",
-                                Integer.valueOf(nameStart),
-                                Integer.valueOf(nameEnd),
-                                null));
+                        extract = "";
+                    }
+                    String message = sm.getString("parameters.invalidChunk",
+                            Integer.valueOf(nameStart),
+                            Integer.valueOf(valueEnd), extract);
+                    switch (logMode) {
+                        case INFO_THEN_DEBUG:
+                            message += sm.getString("parameters.fallToDebug");
+                            //$FALL-THROUGH$
+                        case INFO:
+                            log.info(message);
+                            break;
+                        case DEBUG:
+                            log.debug(message);
                     }
                 }
                 parseFailed = true;
@@ -402,8 +428,22 @@ public final class Parameters {
                         log.debug(sm.getString("parameters.decodeFail.debug",
                                 origName.toString(), origValue.toString()), e);
                     } else if (log.isInfoEnabled()) {
-                        log.info(sm.getString("parameters.decodeFail.info",
-                                tmpName.toString(), tmpValue.toString()), e);
+                        UserDataHelper.Mode logMode = 
userDataLog.getNextMode();
+                        if (logMode != null) {
+                            String message = sm.getString(
+                                    "parameters.decodeFail.info",
+                                    tmpName.toString(), tmpValue.toString());
+                            switch (logMode) {
+                                case INFO_THEN_DEBUG:
+                                    message += 
sm.getString("parameters.fallToDebug");
+                                    //$FALL-THROUGH$
+                                case INFO:
+                                    log.info(message);
+                                    break;
+                                case DEBUG:
+                                    log.debug(message);
+                            }
+                        }
                     }
                 }
             }
@@ -418,8 +458,22 @@ public final class Parameters {
         }
 
         if (decodeFailCount > 1 && !log.isDebugEnabled()) {
-            log.info(sm.getString("parameters.multipleDecodingFail",
-                    Integer.valueOf(decodeFailCount)));
+            UserDataHelper.Mode logMode = userDataLog.getNextMode();
+            if (logMode != null) {
+                String message = sm.getString(
+                        "parameters.multipleDecodingFail",
+                        Integer.valueOf(decodeFailCount));
+                switch (logMode) {
+                    case INFO_THEN_DEBUG:
+                        message += sm.getString("parameters.fallToDebug");
+                        //$FALL-THROUGH$
+                    case INFO:
+                        log.info(message);
+                        break;
+                    case DEBUG:
+                        log.debug(message);
+                }
+            }
         }
     }
 

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1476728&r1=1476727&r2=1476728&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Sun Apr 28 07:55:14 2013
@@ -47,6 +47,9 @@
   <subsection name="Catalina">
     <changelog>
       <fix>
+        <bug>52184</bug>: Reduce log level for invalid cookies. (markt)
+      </fix>
+      <fix>
         <bug>53481</bug>: Added support for SSLHonorCipherOrder to allow
         the server to impose its cipher order on the client. Based on a patch
         provided by Marcel &#x160;ebek. (schultz)

Modified: tomcat/tc6.0.x/trunk/webapps/docs/config/systemprops.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/config/systemprops.xml?rev=1476728&r1=1476727&r2=1476728&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/config/systemprops.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/config/systemprops.xml Sun Apr 28 
07:55:14 2013
@@ -377,6 +377,45 @@
 </section>
 
 
+<section name="Logging">
+
+  <properties>
+
+    <property name="org.apache.juli.logging. UserDataHelper.CONFIG">
+      <p>The type of logging to use for errors generated by invalid input data.
+         The options are: <code>DEBUG_ALL</code>, <code>INFO_THEN_DEBUG</code>,
+         <code>INFO_ALL</code> and <code>NONE</code>. When
+         <code>INFO_THEN_DEBUG</code> is used, the period for which errors are
+         logged at DEBUG rather than INFO is controlled by the system property
+         <code>org.apache.juli.logging.UserDataHelper.SUPPRESSION_TIME</code>.
+         </p>
+      <p>The default value is <code>INFO_THEN_DEBUG</code>.</p>
+      <p>The errors currently logged using this system are:
+         <ul>
+         <li>invalid parameters.</li>
+         </ul>
+         Other errors triggered by invalid input data may be added to this
+         system in later versions.</p>
+    </property>
+
+    <property name="org.apache.juli.logging. UserDataHelper.SUPPRESSION_TIME">
+      <p>When using <code>INFO_THEN_DEBUG</code> for
+         <code>org.apache.juli.logging.UserDataHelper.CONFIG</code> this system
+         property controls how long messages are logged at DEBUG after a 
message
+         has been logged at INFO. Once this period has elapsed, the next 
message
+         will be logged at INFO followed by a new suppression period where
+         messages are logged at DEBUG and so on. The value is measured
+         in seconds.</p>
+      <p>A value of <code>0</code> is equivalent to using <code>INFO_ALL</code>
+         for <code>org.apache.juli.logging.UserDataHelper.CONFIG</code>.</p>
+      <p>A negative value means an infinite suppression period.</p>
+      <p>The default value is <code>86400</code> (24 hours).</p>
+    </property>
+  </properties>
+
+</section>
+
+
 <section name="Other">
 
   <properties>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to