Skip to content

Apache Lucene open-source search software

SOLR-1538: Reordering of object allocations in ConcurrentLRUCache to eliminate (an extremeely small) potential for deadlock.

Chris M. Hostetter42e8d5c2c7b4
diff --git a/CHANGES.txt b/CHANGES.txt
index 5a904f08731..81db5bc1e94 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -196,6 +196,11 @@ Other Changes
* SOLR-1268: Add Lucene 2.9-dev r888785 FastVectorHighlighter contrib jar to lib. (koji)
+* SOLR-1538: Reordering of object allocations in ConcurrentLRUCache to eliminate
+ (an extremeely small) potential for deadlock.
+ (gabriele renzi via hossman)
+
+
Build
----------------------
diff --git a/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java b/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java
index 3fdece8a825..19df0acda19 100644
--- a/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java
+++ b/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java
@@ -397,9 +397,9 @@ public class ConcurrentLRUCache<K,V> {
* @return a LinkedHashMap containing 'n' or less than 'n' entries
*/
public Map<K, V> getOldestAccessedItems(int n) {
- markAndSweepLock.lock();
Map<K, V> result = new LinkedHashMap<K, V>();
TreeSet<CacheEntry> tree = new TreeSet<CacheEntry>();
+ markAndSweepLock.lock();
try {
for (Map.Entry<Object, CacheEntry<K,V>> entry : map.entrySet()) {
CacheEntry ce = entry.getValue();
@@ -423,10 +423,10 @@ public class ConcurrentLRUCache<K,V> {
}
public Map<K,V> getLatestAccessedItems(int n) {
- // we need to grab the lock since we are changing lastAccessedCopy
- markAndSweepLock.lock();
Map<K,V> result = new LinkedHashMap<K,V>();
TreeSet<CacheEntry> tree = new TreeSet<CacheEntry>();
+ // we need to grab the lock since we are changing lastAccessedCopy
+ markAndSweepLock.lock();
try {
for (Map.Entry<Object, CacheEntry<K,V>> entry : map.entrySet()) {
CacheEntry<K,V> ce = entry.getValue();