Index: lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java =================================================================== --- lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java (revision 1098156) +++ lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java (working copy) @@ -1051,18 +1051,20 @@ private static Directory newFSDirectoryImpl( Class clazz, File file, LockFactory lockFactory) throws IOException { + FSDirectory d = null; try { // Assuming every FSDirectory has a ctor(File), but not all may take a // LockFactory too, so setting it afterwards. Constructor ctor = clazz.getConstructor(File.class); - FSDirectory d = ctor.newInstance(file); - if (lockFactory != null) { - d.setLockFactory(lockFactory); - } + d = ctor.newInstance(file); return d; } catch (Exception e) { - return FSDirectory.open(file); + d = FSDirectory.open(file); } + if (lockFactory != null) { + d.setLockFactory(lockFactory); + } + return d; } static Directory newDirectoryImpl(Random random, String clazzName) {