mirror of https://github.com/apache/lucene.git
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:
parent
333645af1b
commit
ce164ff8de
|
@ -27,6 +27,7 @@ import java.nio.channels.FileChannel;
|
||||||
import java.nio.channels.SeekableByteChannel;
|
import java.nio.channels.SeekableByteChannel;
|
||||||
import java.nio.file.FileSystem;
|
import java.nio.file.FileSystem;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.NoSuchFileException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -211,6 +212,30 @@ public class TestMockFilesystems extends LuceneTestCase {
|
||||||
file.close();
|
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 {
|
public void testTooManyOpenFiles() throws IOException {
|
||||||
int n = 60;
|
int n = 60;
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,8 @@ public class VerboseFS extends FilterFileSystemProvider {
|
||||||
} finally {
|
} finally {
|
||||||
if (containsDestructive(options)) {
|
if (containsDestructive(options)) {
|
||||||
sop("newFileChannel" + options + ": " + path(path), exception);
|
sop("newFileChannel" + options + ": " + path(path), exception);
|
||||||
|
} else {
|
||||||
|
IOUtils.reThrow(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
|
@ -182,6 +184,8 @@ public class VerboseFS extends FilterFileSystemProvider {
|
||||||
} finally {
|
} finally {
|
||||||
if (containsDestructive(options)) {
|
if (containsDestructive(options)) {
|
||||||
sop("newAsynchronousFileChannel" + options + ": " + path(path), exception);
|
sop("newAsynchronousFileChannel" + options + ": " + path(path), exception);
|
||||||
|
} else {
|
||||||
|
IOUtils.reThrow(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
|
@ -197,6 +201,8 @@ public class VerboseFS extends FilterFileSystemProvider {
|
||||||
} finally {
|
} finally {
|
||||||
if (containsDestructive(options)) {
|
if (containsDestructive(options)) {
|
||||||
sop("newByteChannel" + options + ": " + path(path), exception);
|
sop("newByteChannel" + options + ": " + path(path), exception);
|
||||||
|
} else {
|
||||||
|
IOUtils.reThrow(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
|
@ -271,6 +277,8 @@ public class VerboseFS extends FilterFileSystemProvider {
|
||||||
} finally {
|
} finally {
|
||||||
if (containsDestructive(options)) {
|
if (containsDestructive(options)) {
|
||||||
sop("newByteChannel[SECURE]" + options + ": " + path(path), exception);
|
sop("newByteChannel[SECURE]" + options + ": " + path(path), exception);
|
||||||
|
} else {
|
||||||
|
IOUtils.reThrow(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
|
|
Loading…
Reference in New Issue