Apache Lucene open-source search software
VerboseFS shouldn't suppress exceptions if it doesn't want to log them
Michael McCandlessce164ff8de22
diff --git a/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java b/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.javaindex e0287103665..70857a6b39f 100644--- a/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java+++ b/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java@@ -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;diff --git a/lucene/test-framework/src/java/org/apache/lucene/mockfile/VerboseFS.java b/lucene/test-framework/src/java/org/apache/lucene/mockfile/VerboseFS.javaindex b6d463c19b0..4d39c8621d0 100644--- a/lucene/test-framework/src/java/org/apache/lucene/mockfile/VerboseFS.java+++ b/lucene/test-framework/src/java/org/apache/lucene/mockfile/VerboseFS.java@@ -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();