You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2014/12/02 10:21:23 UTC

svn commit: r1642827 - in /lucene/dev/trunk: ./ lucene/ lucene/core/ lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java lucene/test-framework/ lucene/test-framework/src/java/org/apache/lucene/mockfile/VerboseFS.java

Author: mikemccand
Date: Tue Dec  2 09:21:22 2014
New Revision: 1642827

URL: http://svn.apache.org/r1642827
Log:
VerboseFS shouldn't suppress exceptions if it doesn't want to log them

Modified:
    lucene/dev/trunk/   (props changed)
    lucene/dev/trunk/lucene/   (props changed)
    lucene/dev/trunk/lucene/core/   (props changed)
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java
    lucene/dev/trunk/lucene/test-framework/   (props changed)
    lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/VerboseFS.java

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java?rev=1642827&r1=1642826&r2=1642827&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java Tue Dec  2 09:21:22 2014
@@ -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
     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;
 

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/VerboseFS.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/VerboseFS.java?rev=1642827&r1=1642826&r2=1642827&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/VerboseFS.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/VerboseFS.java Tue Dec  2 09:21:22 2014
@@ -167,6 +167,8 @@ public class VerboseFS extends FilterFil
     } 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 FilterFil
     } 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 FilterFil
     } 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 FilterFil
       } finally {
         if (containsDestructive(options)) {
           sop("newByteChannel[SECURE]" + options + ": " + path(path), exception);
+        } else {
+          IOUtils.reThrow(exception);
         }
       }
       throw new AssertionError();