You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2011/05/01 18:55:13 UTC

svn commit: r1098367 - /lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java

Author: simonw
Date: Sun May  1 16:55:13 2011
New Revision: 1098367

URL: http://svn.apache.org/viewvc?rev=1098367&view=rev
Log:
LUCENE-3057: LuceneTestCase#newFSDirectoryImpl misses to set LockFactory if ctor call throws exception

Modified:
    lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java

Modified: lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java?rev=1098367&r1=1098366&r2=1098367&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java Sun May  1 16:55:13 2011
@@ -1051,18 +1051,20 @@ public abstract class LuceneTestCase ext
   private static Directory newFSDirectoryImpl(
       Class<? extends FSDirectory> 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<? extends FSDirectory> 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) {