You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2014/03/22 12:06:02 UTC
svn commit: r1580192 - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/core/ lucene/core/src/java/org/apache/lucene/index/
lucene/core/src/java/org/apache/lucene/store/
lucene/core/src/test/org/apache/lucene/index/
lucene/core/src/test/org/apache/...
Author: uschindler
Date: Sat Mar 22 11:06:01 2014
New Revision: 1580192
URL: http://svn.apache.org/r1580192
Log:
LUCENE-5550: Merged revision(s) 1491222, 1491992 from lucene/dev/trunk:
- fix test to catch also NoSuchFileException
- LUCENE-5047: Handle NoSuchFileException of Java 7 like FileNotFoundException when opeining index files; document this in Directory
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/Directory.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java
lucene/dev/branches/branch_4x/lucene/replicator/ (props changed)
lucene/dev/branches/branch_4x/lucene/test-framework/ (props changed)
lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java?rev=1580192&r1=1580191&r2=1580192&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java Sat Mar 22 11:06:01 2014
@@ -19,6 +19,7 @@ package org.apache.lucene.index;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.nio.file.NoSuchFileException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -291,7 +292,7 @@ public abstract class DirectoryReader ex
// IOException allowed to throw there, in case
// segments_N is corrupt
sis.read(dir, fileName);
- } catch (FileNotFoundException fnfe) {
+ } catch (FileNotFoundException | NoSuchFileException fnfe) {
// LUCENE-948: on NFS (and maybe others), if
// you have writers switching back and forth
// between machines, it's very likely that the
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java?rev=1580192&r1=1580191&r2=1580192&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java Sat Mar 22 11:06:01 2014
@@ -20,6 +20,7 @@ package org.apache.lucene.index;
import java.io.Closeable;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.nio.file.NoSuchFileException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -170,7 +171,7 @@ final class IndexFileDeleter implements
SegmentInfos sis = new SegmentInfos();
try {
sis.read(directory, fileName);
- } catch (FileNotFoundException e) {
+ } catch (FileNotFoundException | NoSuchFileException e) {
// LUCENE-948: on NFS (and maybe others), if
// you have writers switching back and forth
// between machines, it's very likely that the
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/Directory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/Directory.java?rev=1580192&r1=1580191&r2=1580192&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/Directory.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/Directory.java Sat Mar 22 11:06:01 2014
@@ -21,6 +21,7 @@ import java.io.EOFException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Closeable;
+import java.nio.file.NoSuchFileException;
import java.util.Collection; // for javadocs
import org.apache.lucene.util.IOUtils;
@@ -64,8 +65,8 @@ public abstract class Directory implemen
* Returns the length of a file in the directory. This method follows the
* following contract:
* <ul>
- * <li>Must throw {@link FileNotFoundException} if the file does not exist
- * (not {@code java.nio.file.NoSuchFileException} of Java 7).
+ * <li>Throws {@link FileNotFoundException} or {@link NoSuchFileException}
+ * if the file does not exist.
* <li>Returns a value ≥0 if the file exists, which specifies its length.
* </ul>
*
@@ -100,8 +101,8 @@ public abstract class Directory implemen
* the only Directory implementations that respect this
* parameter are {@link FSDirectory} and {@link
* CompoundFileDirectory}.
- * <li>Must throw {@link FileNotFoundException} if the file does not exist
- * (not {@code java.nio.file.NoSuchFileException} of Java 7).
+ * <p>Throws {@link FileNotFoundException} or {@link NoSuchFileException}
+ * if the file does not exist.
*/
public abstract IndexInput openInput(String name, IOContext context) throws IOException;
@@ -208,8 +209,8 @@ public abstract class Directory implemen
* efficiently open one or more sliced {@link IndexInput} instances from a
* single file handle. The underlying file handle is kept open until the
* {@link IndexInputSlicer} is closed.
- * <li>Must throw {@link FileNotFoundException} if the file does not exist
- * (not {@code java.nio.file.NoSuchFileException} of Java 7).
+ * <p>Throws {@link FileNotFoundException} or {@link NoSuchFileException}
+ * if the file does not exist.
*
* @throws IOException
* if an {@link IOException} occurs
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java?rev=1580192&r1=1580191&r2=1580192&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java Sat Mar 22 11:06:01 2014
@@ -19,6 +19,7 @@ package org.apache.lucene.index;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.nio.file.NoSuchFileException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -890,7 +891,7 @@ public class TestAddIndexes extends Luce
if (t instanceof AlreadyClosedException || t instanceof MergePolicy.MergeAbortedException || t instanceof NullPointerException) {
report = !didClose;
- } else if (t instanceof FileNotFoundException) {
+ } else if (t instanceof FileNotFoundException || t instanceof NoSuchFileException) {
report = !didClose;
} else if (t instanceof IOException) {
Throwable t2 = t.getCause();
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java?rev=1580192&r1=1580191&r2=1580192&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java Sat Mar 22 11:06:01 2014
@@ -20,6 +20,7 @@ package org.apache.lucene.index;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.nio.file.NoSuchFileException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
@@ -428,8 +429,8 @@ void assertTermDocsCount(String msg,
}
try {
DirectoryReader.open(fileDirName);
- fail("opening DirectoryReader on empty directory failed to produce FileNotFoundException");
- } catch (FileNotFoundException e) {
+ fail("opening DirectoryReader on empty directory failed to produce FileNotFoundException/NoSuchFileException");
+ } catch (FileNotFoundException | NoSuchFileException e) {
// GOOD
}
rmDir(fileDirName);
@@ -470,8 +471,8 @@ public void testFilesOpenClose() throws
Directory dir = newFSDirectory(dirFile);
try {
DirectoryReader.open(dir);
- fail("expected FileNotFoundException");
- } catch (FileNotFoundException e) {
+ fail("expected FileNotFoundException/NoSuchFileException");
+ } catch (FileNotFoundException | NoSuchFileException e) {
// expected
}
@@ -480,8 +481,8 @@ public void testFilesOpenClose() throws
// Make sure we still get a CorruptIndexException (not NPE):
try {
DirectoryReader.open(dir);
- fail("expected FileNotFoundException");
- } catch (FileNotFoundException e) {
+ fail("expected FileNotFoundException/NoSuchFileException");
+ } catch (FileNotFoundException | NoSuchFileException e) {
// expected
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=1580192&r1=1580191&r2=1580192&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java Sat Mar 22 11:06:01 2014
@@ -21,6 +21,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
+import java.nio.file.NoSuchFileException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -1684,7 +1685,7 @@ public class TestIndexWriterExceptions e
} catch (CorruptIndexException ex) {
// Exceptions are fine - we are running out of file handlers here
continue;
- } catch (FileNotFoundException ex) {
+ } catch (FileNotFoundException | NoSuchFileException ex) {
continue;
}
failure.clearDoFail();
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java?rev=1580192&r1=1580191&r2=1580192&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java Sat Mar 22 11:06:01 2014
@@ -19,6 +19,7 @@ package org.apache.lucene.index;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.nio.file.NoSuchFileException;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
@@ -38,10 +39,10 @@ public class TestIndexWriterLockRelease
Directory dir = newFSDirectory(TestUtil.getTempDir("testLockRelease"));
try {
new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
- } catch (FileNotFoundException e) {
+ } catch (FileNotFoundException | NoSuchFileException e) {
try {
new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
- } catch (FileNotFoundException e1) {
+ } catch (FileNotFoundException | NoSuchFileException e1) {
}
} finally {
dir.close();
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java?rev=1580192&r1=1580191&r2=1580192&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java Sat Mar 22 11:06:01 2014
@@ -20,6 +20,7 @@ package org.apache.lucene.store;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.nio.file.NoSuchFileException;
import java.util.Arrays;
import org.apache.lucene.store.MockDirectoryWrapper.Throttling;
@@ -98,7 +99,7 @@ public class TestDirectory extends Lucen
try {
IndexInput input = dir.openInput(file, newIOContext(random()));
input.close();
- } catch (FileNotFoundException e) {
+ } catch (FileNotFoundException | NoSuchFileException e) {
// ignore
} catch (IOException e) {
if (e.getMessage().contains("still open for writing")) {
Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java?rev=1580192&r1=1580191&r2=1580192&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java Sat Mar 22 11:06:01 2014
@@ -20,6 +20,7 @@ package org.apache.lucene.store;
import java.io.Closeable;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.nio.file.NoSuchFileException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -381,7 +382,7 @@ public class MockDirectoryWrapper extend
if (randomState.nextBoolean()) {
throw new IOException("a random IOException (" + name + ")");
} else {
- throw new FileNotFoundException("a random IOException (" + name + ")");
+ throw randomState.nextBoolean() ? new FileNotFoundException("a random IOException (" + name + ")") : new NoSuchFileException("a random IOException (" + name + ")");
}
}
}
@@ -549,7 +550,7 @@ public class MockDirectoryWrapper extend
maybeThrowDeterministicException();
}
if (!in.fileExists(name)) {
- throw new FileNotFoundException(name + " in dir=" + in);
+ throw randomState.nextBoolean() ? new FileNotFoundException(name + " in dir=" + in) : new NoSuchFileException(name + " in dir=" + in);
}
// cannot open a file for input if it's still open for
@@ -925,7 +926,7 @@ public class MockDirectoryWrapper extend
throws IOException {
maybeYield();
if (!in.fileExists(name)) {
- throw new FileNotFoundException(name);
+ throw randomState.nextBoolean() ? new FileNotFoundException(name) : new NoSuchFileException(name);
}
// cannot open a file for input if it's still open for
// output, except for segments.gen and segments_N