lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1457292 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/java/org/apache/solr/core/CachingDirectoryFactory.java core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java
Date Sat, 16 Mar 2013 19:01:11 GMT
Author: markrmiller
Date: Sat Mar 16 19:01:11 2013
New Revision: 1457292

URL: http://svn.apache.org/r1457292
Log:
SOLR-4595: CachingDirectoryFactory#close can throw a concurrent modification exception.

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1457292&r1=1457291&r2=1457292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Sat Mar 16 19:01:11 2013
@@ -137,6 +137,9 @@ Bug Fixes
 * SOLR-4573: Accessing Admin UI files in SolrCloud mode logs warnings.
   (Mark Miller, Phil John)
 
+* SOLR-4595: CachingDirectoryFactory#close can throw a concurrent 
+  modification exception. (Mark Miller)
+
 Optimizations
 ----------------------
 

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java?rev=1457292&r1=1457291&r2=1457292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java
(original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java
Sat Mar 16 19:01:11 2013
@@ -20,6 +20,7 @@ package org.apache.solr.core;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
@@ -123,7 +124,9 @@ public abstract class CachingDirectoryFa
   public void close() throws IOException {
     synchronized (this) {
       this.closed = true;
-      for (CacheValue val : byDirectoryCache.values()) {
+      Collection<CacheValue> values = new ArrayList<CacheValue>();
+      values.addAll(byDirectoryCache.values());
+      for (CacheValue val : values) {
         try {
           // if there are still refs out, we have to wait for them
           int cnt = 0;
@@ -135,7 +138,15 @@ public abstract class CachingDirectoryFa
               break;
             }
           }
-          
+          assert val.refCnt == 0 : val.refCnt;
+        } catch (Throwable t) {
+          SolrException.log(log, "Error closing directory", t);
+        }
+      }
+      
+      values = byDirectoryCache.values();
+      for (CacheValue val : values) {
+        try {
           assert val.refCnt == 0 : val.refCnt;
           log.info("Closing directory when closing factory: " + val.path);
           closeDirectory(val);
@@ -143,6 +154,7 @@ public abstract class CachingDirectoryFa
           SolrException.log(log, "Error closing directory", t);
         }
       }
+      
       byDirectoryCache.clear();
       byPathCache.clear();
     }

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java?rev=1457292&r1=1457291&r2=1457292&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java
(original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java
Sat Mar 16 19:01:11 2013
@@ -73,6 +73,17 @@ public class CachingDirectoryFactoryTest
       thread.join();
     }
     
+    Thread thread = new Thread() {
+      public void run() {
+        try {
+          df.close();
+        } catch (IOException e) {
+          throw new RuntimeException(e);
+        }
+      }
+    };
+    thread.start();
+    
     // do any remaining releases
     synchronized (dirs) {
       int sz = dirs.size();
@@ -98,7 +109,8 @@ public class CachingDirectoryFactoryTest
       
     }
     
-    df.close();
+    thread.join();
+
   }
   
   private class ReleaseDirThread extends Thread {



Mime
View raw message