Include the seed time when calculating the time taken to create SecureRandom instance...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 25 Mar 2011 11:50:27 +0000 (11:50 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 25 Mar 2011 11:50:27 +0000 (11:50 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1085336 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/util/LocalStrings.properties
java/org/apache/catalina/util/SessionIdGenerator.java
webapps/docs/changelog.xml

index 70d9eaa..af98d77 100644 (file)
@@ -36,6 +36,7 @@ requestUtil.parseParameters.uee=Unable to parse the parameters since the encodin
 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}]
index 8d5a429..49ce6b7 100644 (file)
@@ -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;
     }
 }
index ad1dfed..b9be91e 100644 (file)
         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">