You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by ho...@apache.org on 2010/01/12 00:50:01 UTC

svn commit: r898119 - in /lucene/solr/trunk: CHANGES.txt src/common/org/apache/solr/common/util/ConcurrentLRUCache.java

Author: hossman
Date: Mon Jan 11 23:50:01 2010
New Revision: 898119

URL: http://svn.apache.org/viewvc?rev=898119&view=rev
Log:
SOLR-1538: Reordering of object allocations in ConcurrentLRUCache to eliminate (an extremeely small) potential for deadlock.

Modified:
    lucene/solr/trunk/CHANGES.txt
    lucene/solr/trunk/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java

Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=898119&r1=898118&r2=898119&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Mon Jan 11 23:50:01 2010
@@ -196,6 +196,11 @@
 
 * 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
 ----------------------
 

Modified: lucene/solr/trunk/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java?rev=898119&r1=898118&r2=898119&view=diff
==============================================================================
--- lucene/solr/trunk/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java (original)
+++ lucene/solr/trunk/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java Mon Jan 11 23:50:01 2010
@@ -397,9 +397,9 @@
    * @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 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();