mirror of https://github.com/apache/lucene.git
make all Directory.listAll's sort, and add BaseDirectoryTestCase; add TODO; suppress VirusCheckingFS for another test
This commit is contained in:
parent
9cf74f791c
commit
dd6379c05f
|
@ -699,14 +699,15 @@ final class IndexFileDeleter implements Closeable {
|
|||
infoStream.message("IFD", "delete \"" + names + "\"");
|
||||
}
|
||||
|
||||
// nocommit put annoying windows-specific segments_N heroics back?
|
||||
|
||||
for(String name : names) {
|
||||
try {
|
||||
directory.deleteFile(name);
|
||||
} catch (NoSuchFileException | FileNotFoundException e) {
|
||||
// IndexWriter should only ask us to delete files it knows it wrote, so if we hit this, something is wrong!
|
||||
|
||||
if (Constants.WINDOWS) {
|
||||
// TODO: can we remove this OS-specific hacky logic? If windows deleteFile is buggy, we should instead contain this workaround in
|
||||
// a WindowsFSDirectory ...
|
||||
// LUCENE-6684: we suppress this assert for Windows, since a file could be in a confusing "pending delete" state, and falsely
|
||||
// return NSFE/FNFE
|
||||
} else {
|
||||
|
|
|
@ -754,8 +754,9 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
|||
* IO error
|
||||
*/
|
||||
public IndexWriter(Directory d, IndexWriterConfig conf) throws IOException {
|
||||
if (d instanceof FSDirectory && ((FSDirectory) d).checkPendingDeletions()) {
|
||||
throw new IllegalArgumentException("Directory still has pending deleted files");
|
||||
Directory unwrapped = FilterDirectory.unwrap(d);
|
||||
if (unwrapped instanceof FSDirectory && ((FSDirectory) unwrapped).checkPendingDeletions()) {
|
||||
throw new IllegalArgumentException("Directory still has pending deleted files; cannot initialize IndexWriter");
|
||||
}
|
||||
|
||||
conf.setIndexWriter(this); // prevent reuse by other instances
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.apache.lucene.util.IOUtils;
|
|||
public abstract class Directory implements Closeable {
|
||||
|
||||
/**
|
||||
* Returns an array of strings, one for each entry in the directory.
|
||||
* Returns an array of strings, one for each entry in the directory, in sorted (UTF16, java's String.compare) order.
|
||||
*
|
||||
* @throws IOException in case of IO error
|
||||
*/
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.io.FileNotFoundException;
|
|||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -119,8 +120,12 @@ public class RAMDirectory extends BaseDirectory implements Accountable {
|
|||
// concurrently
|
||||
Set<String> fileNames = fileMap.keySet();
|
||||
List<String> names = new ArrayList<>(fileNames.size());
|
||||
for (String name : fileNames) names.add(name);
|
||||
return names.toArray(new String[names.size()]);
|
||||
for (String name : fileNames) {
|
||||
names.add(name);
|
||||
}
|
||||
String[] namesArray = names.toArray(new String[names.size()]);
|
||||
Arrays.sort(namesArray);
|
||||
return namesArray;
|
||||
}
|
||||
|
||||
public final boolean fileNameExists(String name) {
|
||||
|
|
|
@ -2738,7 +2738,7 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
try {
|
||||
w = new IndexWriter(dir, iwc);
|
||||
} catch (IllegalArgumentException iae) {
|
||||
assertEquals("Directory still has pending deleted files", iae.getMessage());
|
||||
assertEquals("Directory still has pending deleted files; cannot initialize IndexWriter", iae.getMessage());
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.io.StringReader;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
@ -58,8 +59,8 @@ import org.apache.lucene.index.SegmentReader;
|
|||
import org.apache.lucene.index.SortedSetDocValues;
|
||||
import org.apache.lucene.index.SortingMergePolicy;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.Collector;
|
||||
import org.apache.lucene.search.EarlyTerminatingSortingCollector;
|
||||
|
|
|
@ -45,10 +45,12 @@ import org.apache.lucene.search.suggest.Lookup.LookupResult;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
@SuppressFileSystems("VirusCheckingFS")
|
||||
public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
|
||||
|
||||
public void testBasic() throws Exception {
|
||||
|
|
|
@ -33,9 +33,11 @@ import org.apache.lucene.search.suggest.Input;
|
|||
import org.apache.lucene.search.suggest.InputArrayIterator;
|
||||
import org.apache.lucene.search.suggest.Lookup;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
|
||||
@SuppressFileSystems("VirusCheckingFS")
|
||||
public class BlendedInfixSuggesterTest extends LuceneTestCase {
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue