[infinispan-commits] Infinispan SVN: r2348 - branches/4.2.x/lucene-directory/src/main/java/org/infinispan/lucene/readlocks.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Sun Sep 12 17:05:16 EDT 2010


Author: sannegrinovero
Date: 2010-09-12 17:05:16 -0400 (Sun, 12 Sep 2010)
New Revision: 2348

Modified:
   branches/4.2.x/lucene-directory/src/main/java/org/infinispan/lucene/readlocks/DistributedSegmentReadLocker.java
Log:
[ISPN-642] (race condition in lucene index optimization could present a NullPointerException when deleting unused segments)

Modified: branches/4.2.x/lucene-directory/src/main/java/org/infinispan/lucene/readlocks/DistributedSegmentReadLocker.java
===================================================================
--- branches/4.2.x/lucene-directory/src/main/java/org/infinispan/lucene/readlocks/DistributedSegmentReadLocker.java	2010-09-12 20:58:05 UTC (rev 2347)
+++ branches/4.2.x/lucene-directory/src/main/java/org/infinispan/lucene/readlocks/DistributedSegmentReadLocker.java	2010-09-12 21:05:16 UTC (rev 2348)
@@ -159,12 +159,15 @@
       FileCacheKey key = new FileCacheKey(indexName, filename);
       boolean batch = cache.startBatch();
       FileMetadata file = (FileMetadata) cache.withFlags(Flag.SKIP_LOCKING).remove(key);
-      for (int i = 0; i < file.getNumberOfChunks(); i++) {
-         ChunkCacheKey chunkKey = new ChunkCacheKey(indexName, filename, i);
-         cache.withFlags(Flag.SKIP_REMOTE_LOOKUP).removeAsync(chunkKey);  
+      if (file != null) { //during optimization of index a same file could be deleted twice, so you could see a null here
+         for (int i = 0; i < file.getNumberOfChunks(); i++) {
+            ChunkCacheKey chunkKey = new ChunkCacheKey(indexName, filename, i);
+            cache.withFlags(Flag.SKIP_REMOTE_LOOKUP).removeAsync(chunkKey);
+         }
+         cache.withFlags(Flag.SKIP_REMOTE_LOOKUP).removeAsync(key);
       }
-      cache.withFlags(Flag.SKIP_REMOTE_LOOKUP).removeAsync(key);
-      //last operation, as being set as value==0 it prevents others from using it during the deletion process:
+      // last operation, as being set as value==0 it prevents others from using it during the
+      // deletion process:
       cache.withFlags(Flag.SKIP_REMOTE_LOOKUP).removeAsync(readLockKey);
       if (batch) {
          cache.endBatch(true);



More information about the infinispan-commits mailing list