Index: src/java/org/apache/lucene/store/FSDirectory.java
===================================================================
--- src/java/org/apache/lucene/store/FSDirectory.java (revision 780320)
+++ src/java/org/apache/lucene/store/FSDirectory.java (working copy)
@@ -27,6 +27,7 @@
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
+import java.lang.reflect.Constructor;
import org.apache.lucene.index.IndexFileNameFilter;
import org.apache.lucene.util.Constants;
@@ -99,7 +100,7 @@
* for some relevant discussion.
* @deprecated Not used by any non-deprecated methods anymore
*/
- private static final Map DIRECTORIES = new HashMap();
+ /*TODO private static final Map DIRECTORIES = new HashMap(); */
private static boolean disableLocks = false;
@@ -137,36 +138,28 @@
* the getDirectory methods that take a
* lockFactory (for example, {@link #getDirectory(String, LockFactory)}).
*/
- public static final String LOCK_DIR = System.getProperty("org.apache.lucene.lockDir",
- System.getProperty("java.io.tmpdir"));
+ public static final String LOCK_DIR =
+ System.getProperty("org.apache.lucene.lockDir", System.getProperty("java.io.tmpdir"));
- /** The default class which implements filesystem-based directories. */
- // deprecated
- private static Class IMPL;
+ // null, if no default by system property
+ private static final String FSDIR_CLASS_NAME;
static {
- try {
- String name =
- System.getProperty("org.apache.lucene.FSDirectory.class",
- FSDirectory.class.getName());
- IMPL = Class.forName(name);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("cannot load FSDirectory class: " + e.toString(), e);
- } catch (SecurityException se) {
- try {
- IMPL = Class.forName(FSDirectory.class.getName());
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("cannot load default FSDirectory class: " + e.toString(), e);
- }
+ String v = System.getProperty("org.apache.lucene.FSDirectory.class");
+ if (FSDirectory.class.getName().equals(v)) {
+ v = SimpleFSDirectory.class.getName();
}
+ FSDIR_CLASS_NAME = v;
}
- private static MessageDigest DIGESTER;
+ private static final String LOCK_CLASS_NAME =
+ System.getProperty("org.apache.lucene.store.FSDirectoryLockFactoryClass");
+ private static MessageDigest DIGESTER;
static {
try {
DIGESTER = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e.toString(), e);
+ throw new RuntimeException(e.toString(), e);
}
}
@@ -175,9 +168,6 @@
/** Returns the directory instance for the named location.
- *
- * @deprecated Use {@link #open(File)}
- *
* @param path the path to the directory.
* @return the FSDirectory for the named file. */
public static FSDirectory getDirectory(String path)
@@ -186,9 +176,6 @@
}
/** Returns the directory instance for the named location.
- *
- * @deprecated Use {@link #open(File, LockFactory)}
- *
* @param path the path to the directory.
* @param lockFactory instance of {@link LockFactory} providing the
* locking implementation.
@@ -199,9 +186,6 @@
}
/** Returns the directory instance for the named location.
- *
- * @deprecated Use {@link #open(File)}
- *
* @param file the path to the directory.
* @return the FSDirectory for the named file. */
public static FSDirectory getDirectory(File file)
@@ -209,30 +193,60 @@
return getDirectory(file, null);
}
- /** Returns the directory instance for the named location.
+ /** Creates an FSDirectory instance, trying to pick the
+ * best implementation given the current environment.
*
- * @deprecated Use {@link #open(File, LockFactory)}
+ *
Currently this returns {@link MMapDirectory} when + * running in a 64 bit JRE, {@link NIOFSDirectory} on + * non-Windows 32 bit JRE, and {@link SimpleFSDirectory} + * on Windows 32 bit JRE. * + *
NOTE: this method may suddenly change which + * implementation is returned from release to release, in + * the event that higher performance defaults become + * possible; if the precise implementation is important to + * your application, please instantiate it directly, + * instead. + * + *
See above + * * @param file the path to the directory. * @param lockFactory instance of {@link LockFactory} providing the * locking implementation. * @return the FSDirectory for the named file. */ - public static FSDirectory getDirectory(File file, LockFactory lockFactory) + public static FSDirectory getDirectory(File path, LockFactory lockFactory) throws IOException { - file = getCanonicalPath(file); + /*TODO path = getCanonicalPath(path);*/ FSDirectory dir; - synchronized (DIRECTORIES) { - dir = (FSDirectory)DIRECTORIES.get(file); - if (dir == null) { - try { - dir = (FSDirectory)IMPL.newInstance(); - } catch (Exception e) { - throw new RuntimeException("cannot load FSDirectory class: " + e.toString(), e); - } - dir.init(file, lockFactory); - DIRECTORIES.put(file, dir); + /*TODO synchronized (DIRECTORIES) { + dir = (FSDirectory)DIRECTORIES.get(path); + if (dir == null) {*/ + if (FSDIR_CLASS_NAME == null || FSDIR_CLASS_NAME.length() == 0) { + // use a platform specific dir impl + if (Constants.JRE_IS_64BIT) { + dir = new MMapDirectory(path, lockFactory); + } else if (Constants.WINDOWS) { + dir = new SimpleFSDirectory(path, lockFactory); + } else { + dir = new NIOFSDirectory(path, lockFactory); + } + } else { + // TODO: Remove this in 3.0 + // use the impl given by system property + try { + final Constructor ctor = Class.forName(FSDIR_CLASS_NAME).getConstructor( + new Class[]{File.class, LockFactory.class} + ); + dir = (FSDirectory)ctor.newInstance( + new Object[]{path, lockFactory} + ); + } catch (Exception e) { + throw new RuntimeException("Unable to instantiate FSDirectory class " + FSDIR_CLASS_NAME, e); + } + }/*TODO + DIRECTORIES.put(path, dir); } else { // Catch the case where a Directory is pulled from the cache, but has a // different LockFactory instance. @@ -244,7 +258,7 @@ } synchronized (dir) { dir.refCount++; - } + }*/ return dir; } @@ -300,9 +314,9 @@ } // returns the canonical version of the directory, creating it if it doesn't exist. - private static File getCanonicalPath(File file) throws IOException { + /*TODO private static File getCanonicalPath(File file) throws IOException { return new File(file.getCanonicalPath()); - } + }*/ private boolean checked; @@ -316,7 +330,7 @@ } } - final void initOutput(String name) throws IOException { + protected final void initOutput(String name) throws IOException { ensureOpen(); createDir(); File file = new File(directory, name); @@ -325,56 +339,19 @@ } protected File directory = null; - private int refCount; + /*TODO private int refCount;*/ - protected FSDirectory() {}; // permit subclassing + //TODO: REMOVE this?: + //protected FSDirectory() {}; /** Create a new FSDirectory for the named location. - * @deprecated Use {@link SimpleFSDirectory#SimpleFSDirectory}. * @param path the path of the directory * @param lockFactory the lock factory to use, or null for the default. * @throws IOException */ - public FSDirectory(File path, LockFactory lockFactory) throws IOException { - path = getCanonicalPath(path); - init(path, lockFactory); - refCount = 1; - } + protected FSDirectory(File path, LockFactory lockFactory) throws IOException { + /*TODO path = getCanonicalPath(path);*/ - /** Creates an FSDirectory instance, trying to pick the - * best implementation given the current environment. - * - *
Currently this returns {@link MMapDirectory} when - * running in a 64 bit JRE, {@link NIOFSDirectory} on - * non-Windows 32 bit JRE, and {@link SimpleFSDirectory} - * on Windows 32 bit JRE. - * - *
NOTE: this method may suddenly change which - * implementation is returned from release to release, in - * the event that higher performance defaults become - * possible; if the precise implementation is important to - * your application, please instantiate it directly, - * instead. - * - *
See above */ - public static FSDirectory open(File path) throws IOException { - return open(path, null); - } - - /** Just like {@link #open(File)}, but allows you to - * also specify a custom {@link LockFactory}. */ - public static FSDirectory open(File path, LockFactory lockFactory) throws IOException { - if (Constants.JRE_IS_64BIT) { - return new MMapDirectory(path, lockFactory); - } else if (Constants.WINDOWS) { - return new SimpleFSDirectory(path, lockFactory); - } else { - return new NIOFSDirectory(path, lockFactory); - } - } - - private void init(File path, LockFactory lockFactory) throws IOException { - // Set up lockFactory with cascaded defaults: if an instance was passed in, // use that; else if locks are disabled, use NoLockFactory; else if the // system property org.apache.lucene.store.FSDirectoryLockFactoryClass is set, @@ -393,27 +370,13 @@ // Locks are disabled: lockFactory = NoLockFactory.getNoLockFactory(); } else { - String lockClassName = System.getProperty("org.apache.lucene.store.FSDirectoryLockFactoryClass"); - - if (lockClassName != null && !lockClassName.equals("")) { - Class c; - + if (LOCK_CLASS_NAME != null && LOCK_CLASS_NAME.length() > 0) { try { - c = Class.forName(lockClassName); - } catch (ClassNotFoundException e) { - throw new IOException("unable to find LockClass " + lockClassName); + lockFactory = (LockFactory) Class.forName(LOCK_CLASS_NAME).newInstance(); + } catch (Exception e) { + throw new RuntimeException("Unable to instantiate LockFactory class " + LOCK_CLASS_NAME, e); } - try { - lockFactory = (LockFactory) c.newInstance(); - } catch (IllegalAccessException e) { - throw new IOException("IllegalAccessException when instantiating LockClass " + lockClassName); - } catch (InstantiationException e) { - throw new IOException("InstantiationException when instantiating LockClass " + lockClassName); - } catch (ClassCastException e) { - throw new IOException("unable to cast LockClass " + lockClassName + " instance to a LockFactory"); - } - if (lockFactory instanceof NativeFSLockFactory) { ((NativeFSLockFactory) lockFactory).setLockDir(path); } else if (lockFactory instanceof SimpleFSLockFactory) { @@ -435,6 +398,8 @@ // stored in our directory: lockFactory.setLockPrefix(null); } + + /*TODO refCount = 1;*/ } /** Lists all files (not subdirectories) in the @@ -680,11 +645,11 @@ /** Closes the store to future operations. */ public synchronized void close() { - if (isOpen && --refCount <= 0) { + if (isOpen/*TODO && --refCount <= 0*/) { isOpen = false; - synchronized (DIRECTORIES) { + /*TODO synchronized (DIRECTORIES) { DIRECTORIES.remove(directory); - } + }*/ } } @@ -699,143 +664,27 @@ } /** @deprecated Use SimpleFSDirectory.SimpleFSIndexInput instead */ - protected static class FSIndexInput extends BufferedIndexInput { + protected static class FSIndexInput extends SimpleFSDirectory.SimpleFSIndexInput { - protected static class Descriptor extends RandomAccessFile { - // remember if the file is open, so that we don't try to close it - // more than once - protected volatile boolean isOpen; - long position; - final long length; - - public Descriptor(File file, String mode) throws IOException { - super(file, mode); - isOpen=true; - length=length(); - } - - public void close() throws IOException { - if (isOpen) { - isOpen=false; - super.close(); - } - } - - protected void finalize() throws Throwable { - try { - close(); - } finally { - super.finalize(); - } - } - } - - protected final Descriptor file; - boolean isClone; - + /** @deprecated */ public FSIndexInput(File path) throws IOException { - this(path, BufferedIndexInput.BUFFER_SIZE); + super(path); } + /** @deprecated */ public FSIndexInput(File path, int bufferSize) throws IOException { - super(bufferSize); - file = new Descriptor(path, "r"); + super(path, bufferSize); } - /** IndexInput methods */ - protected void readInternal(byte[] b, int offset, int len) - throws IOException { - synchronized (file) { - long position = getFilePointer(); - if (position != file.position) { - file.seek(position); - file.position = position; - } - int total = 0; - do { - int i = file.read(b, offset+total, len-total); - if (i == -1) - throw new IOException("read past EOF"); - file.position += i; - total += i; - } while (total < len); - } - } - - public void close() throws IOException { - // only close the file if this is not a clone - if (!isClone) file.close(); - } - - protected void seekInternal(long position) { - } - - public long length() { - return file.length; - } - - public Object clone() { - FSIndexInput clone = (FSIndexInput)super.clone(); - clone.isClone = true; - return clone; - } - - /** Method used for testing. Returns true if the underlying - * file descriptor is valid. - */ - boolean isFDValid() throws IOException { - return file.getFD().valid(); - } } /** @deprecated Use SimpleFSDirectory.SimpleFSIndexOutput instead */ - protected static class FSIndexOutput extends BufferedIndexOutput { - RandomAccessFile file = null; - - // remember if the file is open, so that we don't try to close it - // more than once - private volatile boolean isOpen; + protected static class FSIndexOutput extends SimpleFSDirectory.SimpleFSIndexOutput { + /** @deprecated */ public FSIndexOutput(File path) throws IOException { - file = new RandomAccessFile(path, "rw"); - isOpen = true; + super(path); } - - /** output methods: */ - public void flushBuffer(byte[] b, int offset, int size) throws IOException { - file.write(b, offset, size); - } - public void close() throws IOException { - // only close the file if it has not been closed yet - if (isOpen) { - boolean success = false; - try { - super.close(); - success = true; - } finally { - isOpen = false; - if (!success) { - try { - file.close(); - } catch (Throwable t) { - // Suppress so we don't mask original exception - } - } else - file.close(); - } - } - } - - /** Random-access methods */ - public void seek(long pos) throws IOException { - super.seek(pos); - file.seek(pos); - } - public long length() throws IOException { - return file.length(); - } - public void setLength(long length) throws IOException { - file.setLength(length); - } + } } Index: src/java/org/apache/lucene/store/MMapDirectory.java =================================================================== --- src/java/org/apache/lucene/store/MMapDirectory.java (revision 780320) +++ src/java/org/apache/lucene/store/MMapDirectory.java (working copy) @@ -47,12 +47,6 @@ super(path, lockFactory); } - // back compatibility so FSDirectory can instantiate via - // reflection - /* @deprecated */ - protected MMapDirectory() throws IOException { - } - private static class MMapIndexInput extends IndexInput { private ByteBuffer buffer; @@ -125,7 +119,7 @@ + raf.toString()); int nrBuffers = (int) (length / maxBufSize); - if ((nrBuffers * maxBufSize) < length) nrBuffers++; + if (((long) nrBuffers * maxBufSize) < length) nrBuffers++; this.buffers = new ByteBuffer[nrBuffers]; this.bufSizes = new int[nrBuffers]; @@ -171,13 +165,13 @@ } public long getFilePointer() { - return (curBufIndex * (long) maxBufSize) + curBuf.position(); + return ((long) curBufIndex * (long) maxBufSize) + curBuf.position(); } public void seek(long pos) throws IOException { curBufIndex = (int) (pos / maxBufSize); curBuf = buffers[curBufIndex]; - int bufOffset = (int) (pos - (curBufIndex * maxBufSize)); + int bufOffset = (int) (pos - ((long) curBufIndex * maxBufSize)); curBuf.position(bufOffset); curAvail = bufSizes[curBufIndex] - bufOffset; } Index: src/java/org/apache/lucene/store/NIOFSDirectory.java =================================================================== --- src/java/org/apache/lucene/store/NIOFSDirectory.java (revision 780320) +++ src/java/org/apache/lucene/store/NIOFSDirectory.java (working copy) @@ -50,11 +50,6 @@ super(path, lockFactory); } - // back compatibility so FSDirectory can instantiate via reflection - /* @deprecated */ - protected NIOFSDirectory() throws IOException { - } - // Inherit javadoc public IndexInput openInput(String name, int bufferSize) throws IOException { ensureOpen(); @@ -66,7 +61,7 @@ return new SimpleFSDirectory.SimpleFSIndexOutput(new File(directory, name)); } - private static class NIOFSIndexInput extends FSDirectory.FSIndexInput { + private static class NIOFSIndexInput extends SimpleFSDirectory.SimpleFSIndexInput { private ByteBuffer byteBuf; // wraps the buffer for NIO Index: src/test/org/apache/lucene/index/store/TestRAMDirectory.java =================================================================== --- src/test/org/apache/lucene/index/store/TestRAMDirectory.java (revision 780320) +++ src/test/org/apache/lucene/index/store/TestRAMDirectory.java (working copy) @@ -77,7 +77,7 @@ public void testRAMDirectory () throws IOException { - Directory dir = FSDirectory.open(indexDir); + Directory dir = FSDirectory.getDirectory(indexDir); MockRAMDirectory ramDir = new MockRAMDirectory(dir); // close the underlaying directory Index: src/test/org/apache/lucene/index/TestAtomicUpdate.java =================================================================== --- src/test/org/apache/lucene/index/TestAtomicUpdate.java (revision 780320) +++ src/test/org/apache/lucene/index/TestAtomicUpdate.java (working copy) @@ -190,7 +190,7 @@ // Second in an FSDirectory: String tempDir = System.getProperty("java.io.tmpdir"); File dirPath = new File(tempDir, "lucene.test.atomic"); - directory = FSDirectory.open(dirPath); + directory = FSDirectory.getDirectory(dirPath); runTest(directory); directory.close(); _TestUtil.rmDir(dirPath); Index: src/test/org/apache/lucene/index/TestBackwardsCompatibility.java =================================================================== --- src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (revision 780320) +++ src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (working copy) @@ -134,7 +134,7 @@ String dirName = "src/test/org/apache/lucene/index/index." + oldNames[i]; unzip(dirName, oldNames[i]); String fullPath = fullDir(oldNames[i]); - Directory dir = FSDirectory.open(new File(fullPath)); + Directory dir = FSDirectory.getDirectory(new File(fullPath)); IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED); w.optimize(); w.close(); @@ -195,7 +195,7 @@ dirName = fullDir(dirName); - Directory dir = FSDirectory.open(new File(dirName)); + Directory dir = FSDirectory.getDirectory(new File(dirName)); IndexSearcher searcher = new IndexSearcher(dir); IndexReader reader = searcher.getIndexReader(); @@ -263,7 +263,7 @@ dirName = fullDir(dirName); - Directory dir = FSDirectory.open(new File(dirName)); + Directory dir = FSDirectory.getDirectory(new File(dirName)); // open writer IndexWriter writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false); @@ -325,7 +325,7 @@ dirName = fullDir(dirName); - Directory dir = FSDirectory.open(new File(dirName)); + Directory dir = FSDirectory.getDirectory(new File(dirName)); // make sure searching sees right # hits IndexSearcher searcher = new IndexSearcher(dir); @@ -375,7 +375,7 @@ dirName = fullDir(dirName); - Directory dir = FSDirectory.open(new File(dirName)); + Directory dir = FSDirectory.getDirectory(new File(dirName)); IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); writer.setUseCompoundFile(doCFS); writer.setMaxBufferedDocs(10); @@ -407,7 +407,7 @@ rmDir(outputDir); try { - Directory dir = FSDirectory.open(new File(fullDir(outputDir))); + Directory dir = FSDirectory.getDirectory(new File(fullDir(outputDir))); boolean autoCommit = 0 == pass; Index: src/test/org/apache/lucene/index/TestCompoundFile.java =================================================================== --- src/test/org/apache/lucene/index/TestCompoundFile.java (revision 780320) +++ src/test/org/apache/lucene/index/TestCompoundFile.java (working copy) @@ -62,7 +62,7 @@ super.setUp(); File file = new File(System.getProperty("tempDir"), "testIndex"); _TestUtil.rmDir(file); - dir = FSDirectory.open(file); + dir = FSDirectory.getDirectory(file); } Index: src/test/org/apache/lucene/index/TestDoc.java =================================================================== --- src/test/org/apache/lucene/index/TestDoc.java (revision 780320) +++ src/test/org/apache/lucene/index/TestDoc.java (working copy) @@ -104,7 +104,7 @@ StringWriter sw = new StringWriter(); PrintWriter out = new PrintWriter(sw, true); - Directory directory = FSDirectory.open(indexDir); + Directory directory = FSDirectory.getDirectory(indexDir); IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); SegmentInfo si1 = indexDoc(writer, "test.txt"); @@ -132,7 +132,7 @@ sw = new StringWriter(); out = new PrintWriter(sw, true); - directory = FSDirectory.open(indexDir); + directory = FSDirectory.getDirectory(indexDir); writer = new IndexWriter(directory, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); si1 = indexDoc(writer, "test.txt"); Index: src/test/org/apache/lucene/index/TestFieldsReader.java =================================================================== --- src/test/org/apache/lucene/index/TestFieldsReader.java (revision 780320) +++ src/test/org/apache/lucene/index/TestFieldsReader.java (working copy) @@ -215,7 +215,7 @@ String path = tmpIODir + File.separator + "lazyDir" + userName; File file = new File(path); _TestUtil.rmDir(file); - FSDirectory tmpDir = FSDirectory.open(file); + FSDirectory tmpDir = FSDirectory.getDirectory(file); assertTrue(tmpDir != null); IndexWriter writer = new IndexWriter(tmpDir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); @@ -314,7 +314,7 @@ FSDirectory fsDir; public FaultyFSDirectory(File dir) throws IOException { - fsDir = FSDirectory.open(dir); + fsDir = FSDirectory.getDirectory(dir); lockFactory = fsDir.getLockFactory(); } public IndexInput openInput(String name) throws IOException { Index: src/test/org/apache/lucene/index/TestIndexReader.java =================================================================== --- src/test/org/apache/lucene/index/TestIndexReader.java (revision 780320) +++ src/test/org/apache/lucene/index/TestIndexReader.java (working copy) @@ -537,7 +537,7 @@ throw new IOException("tempDir undefined, cannot run test"); File indexDir = new File(tempDir, "lucenetestnormwriter"); - Directory dir = FSDirectory.open(indexDir); + Directory dir = FSDirectory.getDirectory(indexDir); IndexWriter writer; IndexReader reader; Term searchTerm = new Term("content", "aaa"); @@ -717,7 +717,7 @@ } private Directory getDirectory() throws IOException { - return FSDirectory.open(new File(System.getProperty("tempDir"), "testIndex")); + return FSDirectory.getDirectory(new File(System.getProperty("tempDir"), "testIndex")); } public void testFilesOpenClose() throws IOException @@ -1185,7 +1185,7 @@ public void testOpenReaderAfterDelete() throws IOException { File dirFile = new File(System.getProperty("tempDir"), "deletetest"); - Directory dir = FSDirectory.open(dirFile); + Directory dir = FSDirectory.getDirectory(dirFile); try { IndexReader.open(dir); fail("expected FileNotFoundException"); @@ -1543,7 +1543,7 @@ File indexDir = new File(tempDir, "lucenetestdiralreadyclosed"); try { - FSDirectory dir = FSDirectory.open(indexDir); + FSDirectory dir = FSDirectory.getDirectory(indexDir); IndexWriter w = new IndexWriter(indexDir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED); w.setUseCompoundFile(false); Document doc = new Document(); @@ -1624,7 +1624,7 @@ // good exception public void testNoDir() throws Throwable { String tempDir = System.getProperty("java.io.tmpdir"); - Directory dir = FSDirectory.open(new File(tempDir, "doesnotexist")); + Directory dir = FSDirectory.getDirectory(new File(tempDir, "doesnotexist")); try { IndexReader.open(dir); fail("did not hit expected exception"); Index: src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java =================================================================== --- src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java (revision 780320) +++ src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java (working copy) @@ -86,7 +86,7 @@ // test with a single index: index1 File indexDir1 = new File(tempDir, "lucenetestindex1"); - Directory dir1 = FSDirectory.open(indexDir1); + Directory dir1 = FSDirectory.getDirectory(indexDir1); IndexWriter.unlock(dir1); norms = new ArrayList(); @@ -105,14 +105,14 @@ numDocNorms = 0; File indexDir2 = new File(tempDir, "lucenetestindex2"); - Directory dir2 = FSDirectory.open(indexDir2); + Directory dir2 = FSDirectory.getDirectory(indexDir2); createIndex(dir2); doTestNorms(dir2); // add index1 and index2 to a third index: index3 File indexDir3 = new File(tempDir, "lucenetestindex3"); - Directory dir3 = FSDirectory.open(indexDir3); + Directory dir3 = FSDirectory.getDirectory(indexDir3); createIndex(dir3); IndexWriter iw = new IndexWriter(dir3, anlzr, false, Index: src/test/org/apache/lucene/index/TestIndexReaderReopen.java =================================================================== --- src/test/org/apache/lucene/index/TestIndexReaderReopen.java (revision 780320) +++ src/test/org/apache/lucene/index/TestIndexReaderReopen.java (working copy) @@ -141,12 +141,12 @@ // in each iteration verify the work of previous iteration. // try this once with reopen once recreate, on both RAMDir and FSDir. public void testCommitReopenFS () throws IOException { - Directory dir = FSDirectory.open(indexDir); + Directory dir = FSDirectory.getDirectory(indexDir); doTestReopenWithCommit(dir, true); dir.close(); } public void testCommitRecreateFS () throws IOException { - Directory dir = FSDirectory.open(indexDir); + Directory dir = FSDirectory.getDirectory(indexDir); doTestReopenWithCommit(dir, false); dir.close(); } @@ -1081,7 +1081,7 @@ // LUCENE-1453 public void testFSDirectoryReopen() throws CorruptIndexException, IOException { - Directory dir1 = FSDirectory.open(indexDir, null); + Directory dir1 = FSDirectory.getDirectory(indexDir, null); createIndex(dir1, false); dir1.close(); @@ -1110,7 +1110,7 @@ throw new IOException("java.io.tmpdir undefined, cannot run test"); File indexDir2 = new File(tempDir, "IndexReaderReopen2"); - Directory dir1 = FSDirectory.open(indexDir2); + Directory dir1 = FSDirectory.getDirectory(indexDir2); createIndex(dir1, false); IndexReader lastReader = IndexReader.open(indexDir2); Index: src/test/org/apache/lucene/index/TestIndexWriter.java =================================================================== --- src/test/org/apache/lucene/index/TestIndexWriter.java (revision 780320) +++ src/test/org/apache/lucene/index/TestIndexWriter.java (working copy) @@ -747,7 +747,7 @@ File indexDir = new File(tempDir, "lucenetestindexwriter"); try { - Directory dir = FSDirectory.open(indexDir); + Directory dir = FSDirectory.getDirectory(indexDir); // add one document & close writer IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); @@ -4050,7 +4050,7 @@ // LUCENE-1374 public void testMergeCompressedFields() throws IOException { File indexDir = new File(System.getProperty("tempDir"), "mergecompressedfields"); - Directory dir = FSDirectory.open(indexDir); + Directory dir = FSDirectory.getDirectory(indexDir); try { for(int i=0;i<5;i++) { // Must make a new writer & doc each time, w/ @@ -4207,7 +4207,7 @@ public void testOtherFiles() throws Throwable { File indexDir = new File(System.getProperty("tempDir"), "otherfiles"); - Directory dir = new FSDirectory(indexDir, null); + Directory dir = FSDirectory.getDirectory(indexDir); try { // Create my own random file: Index: src/test/org/apache/lucene/index/TestNorms.java =================================================================== --- src/test/org/apache/lucene/index/TestNorms.java (revision 780320) +++ src/test/org/apache/lucene/index/TestNorms.java (working copy) @@ -81,7 +81,7 @@ // test with a single index: index1 File indexDir1 = new File(tempDir, "lucenetestindex1"); - Directory dir1 = FSDirectory.open(indexDir1); + Directory dir1 = FSDirectory.getDirectory(indexDir1); norms = new ArrayList(); modifiedNorms = new ArrayList(); @@ -99,14 +99,14 @@ numDocNorms = 0; File indexDir2 = new File(tempDir, "lucenetestindex2"); - Directory dir2 = FSDirectory.open(indexDir2); + Directory dir2 = FSDirectory.getDirectory(indexDir2); createIndex(dir2); doTestNorms(dir2); // add index1 and index2 to a third index: index3 File indexDir3 = new File(tempDir, "lucenetestindex3"); - Directory dir3 = FSDirectory.open(indexDir3); + Directory dir3 = FSDirectory.getDirectory(indexDir3); createIndex(dir3); IndexWriter iw = new IndexWriter(dir3,anlzr,false, IndexWriter.MaxFieldLength.LIMITED); Index: src/test/org/apache/lucene/index/TestPayloads.java =================================================================== --- src/test/org/apache/lucene/index/TestPayloads.java (revision 780320) +++ src/test/org/apache/lucene/index/TestPayloads.java (working copy) @@ -160,7 +160,7 @@ // now use a FSDirectory and repeat same test String dirName = "test_payloads"; - dir = FSDirectory.open(new File(dirName)); + dir = FSDirectory.getDirectory(new File(dirName)); performTest(dir); rmDir(dirName); } Index: src/test/org/apache/lucene/index/TestStressIndexing.java =================================================================== --- src/test/org/apache/lucene/index/TestStressIndexing.java (revision 780320) +++ src/test/org/apache/lucene/index/TestStressIndexing.java (working copy) @@ -174,7 +174,7 @@ // FSDir String tempDir = System.getProperty("java.io.tmpdir"); File dirPath = new File(tempDir, "lucene.test.stress"); - directory = FSDirectory.open(dirPath); + directory = FSDirectory.getDirectory(dirPath); runStressTest(directory, true, null); directory.close(); @@ -184,7 +184,7 @@ directory.close(); // With ConcurrentMergeScheduler, in FSDir - directory = FSDirectory.open(dirPath); + directory = FSDirectory.getDirectory(dirPath); runStressTest(directory, true, new ConcurrentMergeScheduler()); directory.close(); @@ -194,7 +194,7 @@ directory.close(); // With ConcurrentMergeScheduler and autoCommit=false, in FSDir - directory = FSDirectory.open(dirPath); + directory = FSDirectory.getDirectory(dirPath); runStressTest(directory, false, new ConcurrentMergeScheduler()); directory.close(); Index: src/test/org/apache/lucene/index/TestThreadedOptimize.java =================================================================== --- src/test/org/apache/lucene/index/TestThreadedOptimize.java (revision 780320) +++ src/test/org/apache/lucene/index/TestThreadedOptimize.java (working copy) @@ -149,7 +149,7 @@ throw new IOException("tempDir undefined, cannot run test"); String dirName = tempDir + "/luceneTestThreadedOptimize"; - directory = FSDirectory.open(new File(dirName)); + directory = FSDirectory.getDirectory(new File(dirName)); runTest(directory, false, new SerialMergeScheduler()); runTest(directory, true, new SerialMergeScheduler()); runTest(directory, false, new ConcurrentMergeScheduler()); Index: src/test/org/apache/lucene/store/TestBufferedIndexInput.java =================================================================== --- src/test/org/apache/lucene/store/TestBufferedIndexInput.java (revision 780320) +++ src/test/org/apache/lucene/store/TestBufferedIndexInput.java (working copy) @@ -212,7 +212,7 @@ public MockFSDirectory(File path, Random rand) throws IOException { this.rand = rand; lockFactory = new NoLockFactory(); - dir = FSDirectory.open(path); + dir = FSDirectory.getDirectory(path); } public IndexInput openInput(String name) throws IOException { Index: src/test/org/apache/lucene/store/TestDirectory.java =================================================================== --- src/test/org/apache/lucene/store/TestDirectory.java (revision 780320) +++ src/test/org/apache/lucene/store/TestDirectory.java (working copy) @@ -35,7 +35,7 @@ } catch (AlreadyClosedException ace) { } - dir = FSDirectory.open(new File(System.getProperty("tempDir"))); + dir = FSDirectory.getDirectory(new File(System.getProperty("tempDir"))); dir.close(); try { dir.createOutput("test"); @@ -138,7 +138,7 @@ // LUCENE-1468 public void testFSDirectoryFilter() throws IOException { - checkDirectoryFilter(FSDirectory.open(new File("test"))); + checkDirectoryFilter(FSDirectory.getDirectory(new File("test"))); } // LUCENE-1468 Index: src/test/org/apache/lucene/store/TestLockFactory.java =================================================================== --- src/test/org/apache/lucene/store/TestLockFactory.java (revision 780320) +++ src/test/org/apache/lucene/store/TestLockFactory.java (working copy) @@ -339,7 +339,7 @@ } public void _testStressLocks(LockFactory lockFactory, String indexDirName) throws Exception { - FSDirectory fs1 = FSDirectory.open(new File(indexDirName), lockFactory); + FSDirectory fs1 = FSDirectory.getDirectory(new File(indexDirName), lockFactory); // First create a 1 doc index: IndexWriter w = new IndexWriter(fs1, new WhitespaceAnalyzer(), true, @@ -389,8 +389,8 @@ public void testNativeFSLockFactoryPrefix() throws IOException { // Make sure we get identical instances: - Directory dir1 = FSDirectory.open(new File("TestLockFactory.8"), new NativeFSLockFactory("TestLockFactory.8")); - Directory dir2 = FSDirectory.open(new File("TestLockFactory.9"), new NativeFSLockFactory("TestLockFactory.9")); + Directory dir1 = FSDirectory.getDirectory(new File("TestLockFactory.8"), new NativeFSLockFactory("TestLockFactory.8")); + Directory dir2 = FSDirectory.getDirectory(new File("TestLockFactory.9"), new NativeFSLockFactory("TestLockFactory.9")); String prefix1 = dir1.getLockFactory().getLockPrefix(); String prefix2 = dir2.getLockFactory().getLockPrefix(); @@ -406,7 +406,7 @@ public void testDefaultFSLockFactoryPrefix() throws IOException { // Make sure we get null prefix: - Directory dir = FSDirectory.open(new File("TestLockFactory.10")); + Directory dir = FSDirectory.getDirectory(new File("TestLockFactory.10")); String prefix = dir.getLockFactory().getLockPrefix();