VerboseFS shouldn't suppress exceptions if it doesn't want to log them

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1642827 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-12-02 09:21:22 +00:00
parent 333645af1b
commit ce164ff8de
2 changed files with 33 additions and 0 deletions

View File

@ -27,6 +27,7 @@ import java.nio.channels.FileChannel;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
@ -211,6 +212,30 @@ public class TestMockFilesystems extends LuceneTestCase {
file.close();
}
public void testVerboseFSNoSuchFileException() throws IOException {
Path dir = FilterPath.unwrap(createTempDir());
FileSystem fs = new VerboseFS(dir.getFileSystem(), InfoStream.NO_OUTPUT).getFileSystem(URI.create("file:///"));
Path wrapped = new FilterPath(dir, fs);
try {
AsynchronousFileChannel.open(wrapped.resolve("doesNotExist.rip"));
fail("did not hit exception");
} catch (NoSuchFileException nsfe) {
// expected
}
try {
FileChannel.open(wrapped.resolve("doesNotExist.rip"));
fail("did not hit exception");
} catch (NoSuchFileException nsfe) {
// expected
}
try {
Files.newByteChannel(wrapped.resolve("stillopen"));
fail("did not hit exception");
} catch (NoSuchFileException nsfe) {
// expected
}
}
public void testTooManyOpenFiles() throws IOException {
int n = 60;

View File

@ -167,6 +167,8 @@ public class VerboseFS extends FilterFileSystemProvider {
} finally {
if (containsDestructive(options)) {
sop("newFileChannel" + options + ": " + path(path), exception);
} else {
IOUtils.reThrow(exception);
}
}
throw new AssertionError();
@ -182,6 +184,8 @@ public class VerboseFS extends FilterFileSystemProvider {
} finally {
if (containsDestructive(options)) {
sop("newAsynchronousFileChannel" + options + ": " + path(path), exception);
} else {
IOUtils.reThrow(exception);
}
}
throw new AssertionError();
@ -197,6 +201,8 @@ public class VerboseFS extends FilterFileSystemProvider {
} finally {
if (containsDestructive(options)) {
sop("newByteChannel" + options + ": " + path(path), exception);
} else {
IOUtils.reThrow(exception);
}
}
throw new AssertionError();
@ -271,6 +277,8 @@ public class VerboseFS extends FilterFileSystemProvider {
} finally {
if (containsDestructive(options)) {
sop("newByteChannel[SECURE]" + options + ": " + path(path), exception);
} else {
IOUtils.reThrow(exception);
}
}
throw new AssertionError();