Index: lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java =================================================================== --- lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java (revision 988752) +++ lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java (working copy) @@ -394,6 +394,8 @@ fail(); } catch (IOException e) { // expected exception + } catch (IllegalArgumentException e) { + // mmapdir will give us this from java.nio.Buffer.position() } finally { reader.close(); } @@ -404,6 +406,8 @@ fail(); } catch (IOException e) { // expected exception + } catch (IllegalArgumentException e) { + // mmapdir will give us this from java.nio.Buffer.position() } finally { reader.close(); } Index: lucene/src/test/org/apache/lucene/index/TestIndexWriter.java =================================================================== --- lucene/src/test/org/apache/lucene/index/TestIndexWriter.java (revision 988752) +++ lucene/src/test/org/apache/lucene/index/TestIndexWriter.java (working copy) @@ -4377,10 +4377,8 @@ @Override public void run() { - Directory dir; - try { - dir = newDirectory(random); - } catch (IOException e) { throw new RuntimeException(e); } + // LUCENE-2239: won't work with NIOFS/MMAP + Directory dir = new MockDirectoryWrapper(new RAMDirectory()); IndexWriter w = null; while(!finish) { try { Index: lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java =================================================================== --- lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (revision 988752) +++ lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (working copy) @@ -27,6 +27,7 @@ import org.apache.lucene.search.FieldCache; import org.apache.lucene.search.FieldCache.CacheEntry; import org.apache.lucene.store.Directory; +import org.apache.lucene.store.MMapDirectory; import org.apache.lucene.store.MockDirectoryWrapper; import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.util.FieldCacheSanityChecker.Insanity; @@ -642,7 +643,11 @@ tmpFile.mkdir(); try { Constructor ctor = clazz.getConstructor(File.class); - return ctor.newInstance(tmpFile); + Directory d = ctor.newInstance(tmpFile); + // try not to enable this hack unless we must. + if (d instanceof MMapDirectory && Constants.WINDOWS && MMapDirectory.UNMAP_SUPPORTED) + ((MMapDirectory)d).setUseUnmap(true); + return d; } catch (Exception e2) { // try .open(File) Method method = clazz.getMethod("open", new Class[] { File.class });