lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r515495 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/index/SegmentInfos.java src/test/org/apache/lucene/index/TestIndexReader.java
Date Wed, 07 Mar 2007 08:45:59 GMT
Author: mikemccand
Date: Wed Mar  7 00:45:58 2007
New Revision: 515495

URL: http://svn.apache.org/viewvc?view=rev&rev=515495
Log:
LUCENE-825: make sure FileNotFoundException is returned if directory.list() returns null

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?view=diff&rev=515495&r1=515494&r2=515495
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Wed Mar  7 00:45:58 2007
@@ -43,6 +43,11 @@
     IndexWriter's mergeSegments, and also during
     IndexWriter.addIndexes.  (Mike McCandless)
 
+ 6. LUCENE-825: If directory is removed after
+    FSDirectory.getDirectory() but before IndexReader.open you now get
+    a FileNotFoundException like Lucene pre-2.1 (before this fix you
+    got an NPE).  (Mike McCandless)
+
 New features
 
  1. LUCENE-759: Added two n-gram-producing TokenFilters.

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java?view=diff&rev=515495&r1=515494&r2=515495
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java Wed Mar  7 00:45:58
2007
@@ -481,6 +481,10 @@
             files = fileDirectory.list();
           }
 
+          if (files == null) {
+            throw new FileNotFoundException("no segments* file found in directory " + directory
+ ": list() returned null");
+          }
+
           gen = getCurrentSegmentGeneration(files);
 
           if (gen == -1) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java?view=diff&rev=515495&r1=515494&r2=515495
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java Wed Mar  7 00:45:58
2007
@@ -974,6 +974,28 @@
       return s;
     }
 
+    public void testOpenReaderAfterDelete() throws IOException {
+      File dirFile = new File(System.getProperty("tempDir"),
+                          "deletetest");
+      Directory dir = FSDirectory.getDirectory(dirFile);
+      try {
+        IndexReader reader = IndexReader.open(dir);
+        fail("expected CorruptIndexException");
+      } catch (FileNotFoundException e) {
+        // expected
+      }
+
+      dirFile.delete();
+
+      // Make sure we still get a CorruptIndexException (not NPE):
+      try {
+        IndexReader reader = IndexReader.open(dir);
+        fail("expected CorruptIndexException");
+      } catch (FileNotFoundException e) {
+        // expected
+      }
+    }
+
     private void deleteReaderReaderConflict(boolean optimize) throws IOException
     {
         Directory dir = getDirectory();



Mime
View raw message