Apache Solr open-source search software
LUCENE-2027: remove Directory.touchFile
Michael McCandless62a40f5c3666
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 409ca5d0123..2368db614f9 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -530,6 +530,9 @@ API ChangesClassCastException when loading lazy fields or NumericFields.(Uwe Schindler, Ryan McKinley, Mike McCandless)+* LUCENE-2027: Directory.touchFile is deprecated and will be removed+ in 4.0. (Mike McCandless)+Optimizations* LUCENE-2990: ArrayUtil/CollectionUtil.*Sort() methods now exit earlydiff --git a/lucene/contrib/db/bdb-je/src/java/org/apache/lucene/store/je/JEDirectory.java b/lucene/contrib/db/bdb-je/src/java/org/apache/lucene/store/je/JEDirectory.javaindex 8e2e760d697..0bbeda51f8e 100644--- a/lucene/contrib/db/bdb-je/src/java/org/apache/lucene/store/je/JEDirectory.java+++ b/lucene/contrib/db/bdb-je/src/java/org/apache/lucene/store/je/JEDirectory.java@@ -199,17 +199,6 @@ public class JEDirectory extends Directory {return new JELock();}- @Override- public void touchFile(String name) throws IOException {- File file = new File(name);- long length = 0L;-- if (file.exists(this))- length = file.getLength();-- file.modify(this, length, System.currentTimeMillis());- }-/*** Once a transaction handle was committed it is no longer valid. In order* to continue using this JEDirectory instance after a commit, thediff --git a/lucene/contrib/db/bdb/src/java/org/apache/lucene/store/db/DbDirectory.java b/lucene/contrib/db/bdb/src/java/org/apache/lucene/store/db/DbDirectory.javaindex 829dbedda3d..2e84262855e 100644--- a/lucene/contrib/db/bdb/src/java/org/apache/lucene/store/db/DbDirectory.java+++ b/lucene/contrib/db/bdb/src/java/org/apache/lucene/store/db/DbDirectory.java@@ -222,19 +222,6 @@ public class DbDirectory extends Directory {return new DbLock();}- @Override- public void touchFile(String name)- throws IOException- {- File file = new File(name);- long length = 0L;-- if (file.exists(this))- length = file.getLength();-- file.modify(this, length, System.currentTimeMillis());- }-/*** Once a transaction handle was committed it is no longer valid. In* order to continue using this DbDirectory instance after a commit, thediff --git a/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java b/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.javaindex 7430076f906..0c097737295 100644--- a/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java+++ b/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java@@ -134,15 +134,6 @@ public class NRTCachingDirectory extends Directory {}}- @Override- public synchronized void touchFile(String name) throws IOException {- if (cache.fileExists(name)) {- cache.touchFile(name);- } else {- delegate.touchFile(name);- }- }-@Overridepublic synchronized void deleteFile(String name) throws IOException {// Delete from both, in case we are currently uncaching:diff --git a/lucene/src/java/org/apache/lucene/index/CompoundFileReader.java b/lucene/src/java/org/apache/lucene/index/CompoundFileReader.javaindex 87c3c7b1ac5..ce77bc94a61 100644--- a/lucene/src/java/org/apache/lucene/index/CompoundFileReader.java+++ b/lucene/src/java/org/apache/lucene/index/CompoundFileReader.java@@ -189,12 +189,6 @@ public class CompoundFileReader extends Directory {return directory.fileModified(fileName);}- /** Set the modified time of the compound file to now. */- @Override- public void touchFile(String name) throws IOException {- directory.touchFile(fileName);- }-/** Not implemented* @throws UnsupportedOperationException */@Overridediff --git a/lucene/src/java/org/apache/lucene/store/Directory.java b/lucene/src/java/org/apache/lucene/store/Directory.javaindex f9e3167ccc2..2aba2e7ef12 100644--- a/lucene/src/java/org/apache/lucene/store/Directory.java+++ b/lucene/src/java/org/apache/lucene/store/Directory.java@@ -65,10 +65,6 @@ public abstract class Directory implements Closeable {public abstract long fileModified(String name)throws IOException;- /** Set the modified time of an existing file to now. */- public abstract void touchFile(String name)- throws IOException;-/** Removes an existing file in the directory. */public abstract void deleteFile(String name)throws IOException;diff --git a/lucene/src/java/org/apache/lucene/store/FSDirectory.java b/lucene/src/java/org/apache/lucene/store/FSDirectory.javaindex fcb79138fb5..c5a83879be9 100644--- a/lucene/src/java/org/apache/lucene/store/FSDirectory.java+++ b/lucene/src/java/org/apache/lucene/store/FSDirectory.java@@ -272,14 +272,6 @@ public abstract class FSDirectory extends Directory {return file.lastModified();}- /** Set the modified time of an existing file to now. */- @Override- public void touchFile(String name) {- ensureOpen();- File file = new File(directory, name);- file.setLastModified(System.currentTimeMillis());- }-/** Returns the length in bytes of a file in the directory. */@Overridepublic long fileLength(String name) throws IOException {diff --git a/lucene/src/java/org/apache/lucene/store/FileSwitchDirectory.java b/lucene/src/java/org/apache/lucene/store/FileSwitchDirectory.javaindex 55236b471b7..495ea02b208 100644--- a/lucene/src/java/org/apache/lucene/store/FileSwitchDirectory.java+++ b/lucene/src/java/org/apache/lucene/store/FileSwitchDirectory.java@@ -114,11 +114,6 @@ public class FileSwitchDirectory extends Directory {return getDirectory(name).fileModified(name);}- @Override- public void touchFile(String name) throws IOException {- getDirectory(name).touchFile(name);- }-@Overridepublic void deleteFile(String name) throws IOException {getDirectory(name).deleteFile(name);diff --git a/lucene/src/java/org/apache/lucene/store/RAMDirectory.java b/lucene/src/java/org/apache/lucene/store/RAMDirectory.javaindex 9d07160a7b2..e33af1a5ee6 100644--- a/lucene/src/java/org/apache/lucene/store/RAMDirectory.java+++ b/lucene/src/java/org/apache/lucene/store/RAMDirectory.java@@ -27,8 +27,6 @@ import java.util.Set;import java.util.concurrent.ConcurrentHashMap;import java.util.concurrent.atomic.AtomicLong;-import org.apache.lucene.util.ThreadInterruptedException;-/*** A memory-resident {@link Directory} implementation. Locking* implementation is by default the {@link SingleInstanceLockFactory}@@ -112,30 +110,6 @@ public class RAMDirectory extends Directory {return file.getLastModified();}- /** Set the modified time of an existing file to now.- * @throws IOException if the file does not exist- */- @Override- public void touchFile(String name) throws IOException {- ensureOpen();- RAMFile file = fileMap.get(name);- if (file == null) {- throw new FileNotFoundException(name);- }-- long ts2, ts1 = System.currentTimeMillis();- do {- try {- Thread.sleep(0, 1);- } catch (InterruptedException ie) {- throw new ThreadInterruptedException(ie);- }- ts2 = System.currentTimeMillis();- } while(ts1 == ts2);-- file.setLastModified(ts2);- }-/** Returns the length in bytes of a file in the directory.* @throws IOException if the file does not exist*/diff --git a/lucene/src/java/org/apache/lucene/store/RAMFile.java b/lucene/src/java/org/apache/lucene/store/RAMFile.javaindex 123f800fba8..4fe78a63d4c 100644--- a/lucene/src/java/org/apache/lucene/store/RAMFile.java+++ b/lucene/src/java/org/apache/lucene/store/RAMFile.java@@ -26,7 +26,6 @@ public class RAMFile {RAMDirectory directory;protected long sizeInBytes;- // This is publicly modifiable via Directory.touchFile(), so direct access not supportedprivate long lastModified = System.currentTimeMillis();// File used as buffer, in no RAMDirectorydiff --git a/lucene/src/test-framework/org/apache/lucene/store/MockDirectoryWrapper.java b/lucene/src/test-framework/org/apache/lucene/store/MockDirectoryWrapper.javaindex c7b0d036dd1..14ee65dc11d 100644--- a/lucene/src/test-framework/org/apache/lucene/store/MockDirectoryWrapper.java+++ b/lucene/src/test-framework/org/apache/lucene/store/MockDirectoryWrapper.java@@ -559,12 +559,6 @@ public class MockDirectoryWrapper extends Directory {return delegate.fileModified(name);}- @Override- public synchronized void touchFile(String name) throws IOException {- maybeYield();- delegate.touchFile(name);- }-@Overridepublic synchronized long fileLength(String name) throws IOException {maybeYield();diff --git a/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java b/lucene/src/test/org/apache/lucene/index/TestFieldsReader.javaindex 75a9be9cc0e..4214263230d 100644--- a/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java+++ b/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java@@ -411,10 +411,6 @@ public class TestFieldsReader extends LuceneTestCase {return fsDir.fileModified(name);}@Override- public void touchFile(String name) throws IOException {- fsDir.touchFile(name);- }- @Overridepublic void deleteFile(String name) throws IOException {fsDir.deleteFile(name);}diff --git a/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java b/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.javaindex cab6a66b266..6066ef9d513 100755--- a/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java+++ b/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java@@ -345,12 +345,6 @@ public class TestBufferedIndexInput extends LuceneTestCase {dir.deleteFile(name);}@Override- public void touchFile(String name)- throws IOException- {- dir.touchFile(name);- }- @Overridepublic long fileModified(String name)throws IOException{