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

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@898119 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2010-01-11 23:50:01 +00:00
parent 10ce9576e3
commit 42e8d5c2c7
2 changed files with 8 additions and 3 deletions

View File

@ -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
----------------------

View File

@ -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();