Index: lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java =================================================================== --- lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java (revision 1201743) +++ lucene/src/java/org/apache/lucene/util/DoubleBarrelLRUCache.java (working copy) @@ -19,6 +19,8 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; +import java.util.Collections; +import java.util.HashMap; import java.util.Map; /** @@ -58,8 +60,13 @@ public DoubleBarrelLRUCache(int maxSize) { this.maxSize = maxSize; countdown = new AtomicInteger(maxSize); - cache1 = new ConcurrentHashMap(); - cache2 = new ConcurrentHashMap(); + if (Constants.JRE_IS_MINIMUM_JAVA6) { + cache1 = new ConcurrentHashMap(); + cache2 = new ConcurrentHashMap(); + } else { + cache1 = Collections.synchronizedMap(new HashMap()); + cache2 = Collections.synchronizedMap(new HashMap()); + } } @SuppressWarnings("unchecked") Index: lucene/src/test/org/apache/lucene/util/TestDoubleBarrelLRUCache.java =================================================================== --- lucene/src/test/org/apache/lucene/util/TestDoubleBarrelLRUCache.java (revision 1201743) +++ lucene/src/test/org/apache/lucene/util/TestDoubleBarrelLRUCache.java (working copy) @@ -21,6 +21,13 @@ public class TestDoubleBarrelLRUCache extends LuceneTestCase { + public void setUp() throws Exception { + super.setUp(); + if (VERBOSE) { + System.out.println("The JRE version to run this test is >= JRE6: " + Constants.JRE_IS_MINIMUM_JAVA6); + } + } + private void testCache(DoubleBarrelLRUCache cache, int n) throws Exception { Object dummy = new Object(); @@ -55,7 +62,7 @@ assertNotNull(cache.get(new CloneableInteger(i))); } } - + public void testLRUCache() throws Exception { final int n = 100; testCache(new DoubleBarrelLRUCache(n), n);