Reduce code duplication
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 17 Nov 2010 16:26:23 +0000 (16:26 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 17 Nov 2010 16:26:23 +0000 (16:26 +0000)
Initialise the random number generator once in ManagerBase

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

java/org/apache/catalina/ha/session/BackupManager.java
java/org/apache/catalina/ha/session/DeltaManager.java
java/org/apache/catalina/session/ManagerBase.java
java/org/apache/catalina/session/PersistentManagerBase.java
java/org/apache/catalina/session/StandardManager.java

index 179f2ff..67f51ed 100644 (file)
@@ -151,8 +151,7 @@ public class BackupManager extends ClusterManagerBase
     @Override
     protected synchronized void startInternal() throws LifecycleException {
         
-        // Force initialization of the random number generator
-        generateSessionId();
+        super.startInternal();
 
         try {
             cluster.registerManager(this);
index ddff94f..c5ef39a 100644 (file)
@@ -737,8 +737,7 @@ public CatalinaCluster getCluster() {
     @Override
     protected synchronized void startInternal() throws LifecycleException {
 
-        // Force initialization of the random number generator
-        generateSessionId();
+       super.startInternal();
 
         // Load unloaded sessions, if any
         try {
index a36b8fb..9cfba8a 100644 (file)
@@ -816,22 +816,29 @@ public abstract class ManagerBase extends LifecycleMBeanBase
     }
 
     @Override
-    protected void destroyInternal() throws LifecycleException {
-        closeRandomFile();
-        super.destroyInternal();
-    }
-    
-    @Override
     protected void initInternal() throws LifecycleException {
         
         super.initInternal();
         
         setDistributable(((Context) getContainer()).getDistributable());
+    }
 
-        // Initialize random number generation
-        getRandomBytes(new byte[16]);
+    @Override
+    protected void startInternal() throws LifecycleException {
+        // Force initialization of the random number generator
+        if (log.isDebugEnabled())
+            log.debug("Force random number initialization starting");
+        generateSessionId();
+        if (log.isDebugEnabled())
+            log.debug("Force random number initialization completed");
     }
 
+    @Override
+    protected void destroyInternal() throws LifecycleException {
+        closeRandomFile();
+        super.destroyInternal();
+    }
+    
     /**
      * Add this Session to the set of active Sessions for this Manager.
      *
index d15b081..9b313ea 100644 (file)
@@ -822,12 +822,7 @@ public abstract class PersistentManagerBase extends ManagerBase {
     @Override
     protected synchronized void startInternal() throws LifecycleException {
 
-        // Force initialization of the random number generator
-        if (log.isDebugEnabled())
-            log.debug("Force random number initialization starting");
-        generateSessionId();
-        if (log.isDebugEnabled())
-            log.debug("Force random number initialization completed");
+       super.startInternal();
 
         if (store == null)
             log.error("No Store configured, persistence disabled");
index 356526b..25416cc 100644 (file)
@@ -458,13 +458,8 @@ public class StandardManager extends ManagerBase {
     @Override
     protected synchronized void startInternal() throws LifecycleException {
 
-        // Force initialization of the random number generator
-        if (log.isDebugEnabled())
-            log.debug("Force random number initialization starting");
-        generateSessionId();
-        if (log.isDebugEnabled())
-            log.debug("Force random number initialization completed");
-
+       super.startInternal();
+       
         // Load unloaded sessions, if any
         try {
             load();