Author: markt
Date: Fri Mar 25 11:50:27 2011
New Revision: 1085336

URL: http://svn.apache.org/viewvc?rev=1085336&view=rev
Log:
Include the seed time when calculating the time taken to create SecureRandom 
instances for session ID generation, report excessive times (greater than 
100ms) at INFO level and provide a value for the message key so a meaningful 
message appears in the logs.

Modified:
    tomcat/trunk/java/org/apache/catalina/util/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/util/SessionIdGenerator.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/util/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/LocalStrings.properties?rev=1085336&r1=1085335&r2=1085336&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/catalina/util/LocalStrings.properties Fri Mar 
25 11:50:27 2011
@@ -36,6 +36,7 @@ requestUtil.parseParameters.uee=Unable t
 requestUtil.urlDecode.missingDigit=The % character must be followed by two 
hexademical digits
 requestUtil.urlDecode.uee=Unable to URL decode the specified input since the 
encoding [{0}] is not supported.
 SecurityUtil.doAsPrivilege=An exception occurs when running the 
PrivilegedExceptionAction block.
+sessionIdGenerator.createRandom=Creation of SecureRandom instance for session 
ID generation using [{0}] took [{1}] milliseconds.
 sessionIdGenerator.random=Exception initializing random number generator of 
class [{0}]. Falling back to java.secure.SecureRandom
 sessionIdGenerator.randomAlgorithm=Exception initializing random number 
generator using algorithm [{0}] 
 sessionIdGenerator.randomProviderException initializing random number 
generator using provider [{0}]

Modified: tomcat/trunk/java/org/apache/catalina/util/SessionIdGenerator.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/SessionIdGenerator.java?rev=1085336&r1=1085335&r2=1085336&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/SessionIdGenerator.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/util/SessionIdGenerator.java Fri Mar 
25 11:50:27 2011
@@ -242,12 +242,13 @@ public class SessionIdGenerator {
             result = new SecureRandom();
         }
 
-        if(log.isDebugEnabled()) {
-            long t2=System.currentTimeMillis();
-            if( (t2-t1) > 100 )
-                log.debug(sm.getString("sessionIdGenerator.createRandom",
-                        Long.valueOf(t2-t1)));
-        }
+        // Force seeding to take place
+        result.nextInt();
+        
+        long t2=System.currentTimeMillis();
+        if( (t2-t1) > 100 )
+            log.info(sm.getString("sessionIdGenerator.createRandom",
+                    result.getAlgorithm(), Long.valueOf(t2-t1)));
         return result;
     }
 }

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1085336&r1=1085335&r2=1085336&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Mar 25 11:50:27 2011
@@ -85,6 +85,12 @@
         Resolve some refactoring TODOs in the implementation of the new Context
         attribute "swallowAbortedUploads". (markt) 
       </update>
+      <fix>
+        Include the seed time when calculating the time taken to create
+        SecureRandom instances for session ID generation, report excessive 
times
+        (greater than 100ms) at INFO level and provide a value for the message
+        key so a meaningful message appears in the logs. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



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

Reply via email to