mirror of https://github.com/apache/lucene.git
LUCENE-825: make sure FileNotFoundException is returned if directory.list() returns null
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@515495 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
810700836f
commit
622d58b3f8
CHANGES.txt
src
|
@ -43,6 +43,11 @@ Bug fixes
|
|||
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.
|
||||
|
|
|
@ -481,6 +481,10 @@ final class SegmentInfos extends Vector {
|
|||
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) {
|
||||
|
|
|
@ -974,6 +974,28 @@ public class TestIndexReader extends TestCase
|
|||
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();
|
||||
|
|
Loading…
Reference in New Issue