tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1224662 - in /tomcat/trunk: java/org/apache/tomcat/util/http/LocalStrings.properties java/org/apache/tomcat/util/http/Parameters.java webapps/docs/config/systemprops.xml
Date Mon, 26 Dec 2011 00:01:03 GMT
Author: kkolinko
Date: Mon Dec 26 00:01:03 2011
New Revision: 1224662

URL: http://svn.apache.org/viewvc?rev=1224662&view=rev
Log:
Apply UserDataHelper to o.a.t.util.http.Parameters

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/http/LocalStrings.properties
    tomcat/trunk/java/org/apache/tomcat/util/http/Parameters.java
    tomcat/trunk/webapps/docs/config/systemprops.xml

Modified: tomcat/trunk/java/org/apache/tomcat/util/http/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/LocalStrings.properties?rev=1224662&r1=1224661&r2=1224662&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/http/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/http/LocalStrings.properties Mon Dec 26 00:01:03
2011
@@ -22,6 +22,7 @@ parameters.invalidChunk=Invalid chunk st
 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.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.
 
 cookies.invalidCookieToken=Cookies: Invalid cookie. Value not a token or quoted value
 cookies.invalidSpecial=Cookies: Unknown Special Cookie

Modified: tomcat/trunk/java/org/apache/tomcat/util/http/Parameters.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/Parameters.java?rev=1224662&r1=1224661&r2=1224662&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/http/Parameters.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/http/Parameters.java Mon Dec 26 00:01:03 2011
@@ -25,6 +25,7 @@ import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.juli.logging.UserDataHelper;
 import org.apache.tomcat.util.buf.B2CConverter;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.CharChunk;
@@ -41,6 +42,8 @@ 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);
+
     protected static final StringManager sm =
         StringManager.getManager("org.apache.tomcat.util.http");
 
@@ -306,20 +309,22 @@ public final class Parameters {
                     continue;
                 }
                 // &=foo&
-                if (log.isInfoEnabled()) {
-                    if (valueEnd >= nameStart && log.isDebugEnabled()) {
-                        String extract = new String(bytes, nameStart,
-                                valueEnd - nameStart, DEFAULT_CHARSET);
-                        log.info(sm.getString("parameters.invalidChunk",
-                                Integer.valueOf(nameStart),
-                                Integer.valueOf(valueEnd),
-                                extract));
+                UserDataHelper.Mode logMode = userDataLog.getNextMode();
+                if (logMode != null) {
+                    String extract;
+                    if (valueEnd >= nameStart) {
+                        extract = new String(bytes, nameStart, valueEnd
+                                - nameStart, DEFAULT_CHARSET);
                     } 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);
+                    if (logMode.fallToDebug()) {
+                        message += sm.getString("parameters.fallToDebug");
                     }
+                    userDataLog.log(logMode, message);
                 }
                 parseFailed = true;
                 continue;
@@ -387,8 +392,17 @@ 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());
+                            if (logMode.fallToDebug()) {
+                                message += sm
+                                        .getString("parameters.fallToDebug");
+                            }
+                            userDataLog.log(logMode, message, e);
+                        }
                     }
                 }
             }
@@ -403,8 +417,16 @@ 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));
+                if (logMode.fallToDebug()) {
+                    message += sm.getString("parameters.fallToDebug");
+                }
+                userDataLog.log(logMode, message);
+            }
         }
     }
 

Modified: tomcat/trunk/webapps/docs/config/systemprops.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/systemprops.xml?rev=1224662&r1=1224661&r2=1224662&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/systemprops.xml (original)
+++ tomcat/trunk/webapps/docs/config/systemprops.xml Mon Dec 26 00:01:03 2011
@@ -499,7 +499,8 @@
       <p>The default value is <code>INFO_THEN_DEBUG</code>.</p>
       <p>The errors currently logged using this system are:
          <ul>
-         <li>invalid cookies.</li>
+         <li>invalid cookies;</li>
+         <li>invalid parameters.</li>
          </ul>
          Other errors triggered by invalid input data may be added to this
          system in later versions.</p>



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


Mime
View raw message