[infinispan-commits] Infinispan SVN: r1675 - trunk/core/src/main/java/org/infinispan/util/concurrent.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Thu Apr 8 11:26:15 EDT 2010
Author: manik.surtani at jboss.com
Date: 2010-04-08 11:26:15 -0400 (Thu, 08 Apr 2010)
New Revision: 1675
Modified:
trunk/core/src/main/java/org/infinispan/util/concurrent/BoundedConcurrentHashMap.java
Log:
Sanity check params
Modified: trunk/core/src/main/java/org/infinispan/util/concurrent/BoundedConcurrentHashMap.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/util/concurrent/BoundedConcurrentHashMap.java 2010-04-08 15:21:33 UTC (rev 1674)
+++ trunk/core/src/main/java/org/infinispan/util/concurrent/BoundedConcurrentHashMap.java 2010-04-08 15:26:15 UTC (rev 1675)
@@ -1137,9 +1137,12 @@
Eviction evictionStrategy, EvictionListener<K, V> evictionListener) {
if (capacity < 0 || concurrencyLevel <= 0)
throw new IllegalArgumentException();
-
+
+ concurrencyLevel = Math.min(capacity / 2, concurrencyLevel); // concurrencyLevel cannot be > capacity/2
+ concurrencyLevel = Math.max(concurrencyLevel, 1); // concurrencyLevel cannot be less than 1
+
// minimum two elements per segment
- if (capacity < (concurrencyLevel * 2))
+ if (capacity < (concurrencyLevel * 2) && capacity != 1)
throw new IllegalArgumentException("Maximum capacity has to be at least twice the concurrencyLevel");
if (evictionStrategy == null || evictionListener == null)
More information about the infinispan-commits
mailing list