You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by lh...@apache.org on 2009/02/14 06:20:18 UTC

svn commit: r744393 - in /incubator/jsecurity/trunk/core/src/org/jsecurity: cache/HashtableCache.java util/SoftHashMap.java

Author: lhazlewood
Date: Sat Feb 14 05:20:17 2009
New Revision: 744393

URL: http://svn.apache.org/viewvc?rev=744393&view=rev
Log:
deprecated HashtableCache

Modified:
    incubator/jsecurity/trunk/core/src/org/jsecurity/cache/HashtableCache.java
    incubator/jsecurity/trunk/core/src/org/jsecurity/util/SoftHashMap.java

Modified: incubator/jsecurity/trunk/core/src/org/jsecurity/cache/HashtableCache.java
URL: http://svn.apache.org/viewvc/incubator/jsecurity/trunk/core/src/org/jsecurity/cache/HashtableCache.java?rev=744393&r1=744392&r2=744393&view=diff
==============================================================================
--- incubator/jsecurity/trunk/core/src/org/jsecurity/cache/HashtableCache.java (original)
+++ incubator/jsecurity/trunk/core/src/org/jsecurity/cache/HashtableCache.java Sat Feb 14 05:20:17 2009
@@ -29,6 +29,9 @@
  * @author Jeremy Haile
  * @author Les Hazlewood
  * @since 0.2
+ *
+ * @deprecated Due to potential memory leaks caused by {@code Hashtable}s, it is highly recommended to avoid using
+ * this class and instead switch to using a {@link SoftHashMapCache SoftHashMapCache}.
  */
 public class HashtableCache extends MapCache {
 

Modified: incubator/jsecurity/trunk/core/src/org/jsecurity/util/SoftHashMap.java
URL: http://svn.apache.org/viewvc/incubator/jsecurity/trunk/core/src/org/jsecurity/util/SoftHashMap.java?rev=744393&r1=744392&r2=744393&view=diff
==============================================================================
--- incubator/jsecurity/trunk/core/src/org/jsecurity/util/SoftHashMap.java (original)
+++ incubator/jsecurity/trunk/core/src/org/jsecurity/util/SoftHashMap.java Sat Feb 14 05:20:17 2009
@@ -49,7 +49,7 @@
     /**
      * The internal HashMap that will hold the SoftReference.
      */
-    private final Map<K, SoftValue<V, K>> map = new HashMap<K, SoftValue<V, K>>();
+    private final Map<K, SoftValue<V, K>> map;
 
     /**
      * The number of &quot;hard&quot; references to hold internally, that is, the number of instances to prevent
@@ -72,7 +72,15 @@
     }
 
     public SoftHashMap(int hardSize) {
+        super();
         HARD_SIZE = hardSize;
+        if ( JavaEnvironment.isAtLeastVersion15() ) {
+            map = new java.util.concurrent.ConcurrentHashMap<K, SoftValue<V, K>>();
+        } else {
+            //TODO - Will we still support 1.3 and 1.4 JVMs?
+            //noinspection unchecked
+            map = (Map)ClassUtils.newInstance("edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap");
+        }
     }
 
     public V get(Object key) {