Second followup to r892341
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 21 Dec 2009 13:31:46 +0000 (13:31 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 21 Dec 2009 13:31:46 +0000 (13:31 +0000)
Small improvements, based on sebb's and my comments.

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

java/org/apache/catalina/session/PersistentManagerBase.java

index 406561f..660affb 100644 (file)
@@ -213,7 +213,7 @@ public abstract class PersistentManagerBase
     /**
      * Sessions currently being swapped in and the associated locks
      */
-    private Map<String,Object> sessionSwapInLocks =
+    private final Map<String,Object> sessionSwapInLocks =
        new HashMap<String,Object>();
 
 
@@ -794,15 +794,14 @@ public abstract class PersistentManagerBase
         /*
          * The purpose of this sync and these locks is to make sure that a
          * session is only loaded once. It doesn't matter if the lock is removed
-         * and then another thread enters this method and trues to load the same
-         * session. That thread will re-creates a swapIn lock for that session,
+         * and then another thread enters this method and tries to load the same
+         * session. That thread will re-create a swapIn lock for that session,
          * quickly find that the session is already in sessions, use it and
          * carry on.
          */
         synchronized (this) {
-            if (sessionSwapInLocks.containsKey(id)) {
-                swapInLock = sessionSwapInLocks.get(id);
-            } else {
+            swapInLock = sessionSwapInLocks.get(id);
+            if (swapInLock == null) {
                 swapInLock = new Object();
                 sessionSwapInLocks.put(id, swapInLock);
             }