lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r784094 - /lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java
Date Fri, 12 Jun 2009 12:27:14 GMT
Author: uschindler
Date: Fri Jun 12 12:27:14 2009
New Revision: 784094

URL: http://svn.apache.org/viewvc?rev=784094&view=rev
Log:
LUCENE-1686: Remove unnecessary NULL check in FindSegmentsFile - cleanup

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java?rev=784094&r1=784093&r2=784094&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentInfos.java Fri Jun 12 12:27:14
2009
@@ -24,7 +24,6 @@
 import org.apache.lucene.store.ChecksumIndexInput;
 import org.apache.lucene.store.NoSuchDirectoryException;
 
-import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.PrintStream;
@@ -522,7 +521,7 @@
    */
   public abstract static class FindSegmentsFile {
     
-    Directory directory;
+    final Directory directory;
 
     public FindSegmentsFile(Directory directory) {
       this.directory = directory;
@@ -589,45 +588,43 @@
           // a stale cache (NFS) we have a better chance of
           // getting the right generation.
           long genB = -1;
-          if (directory != null) {
-            for(int i=0;i<defaultGenFileRetryCount;i++) {
-              IndexInput genInput = null;
+          for(int i=0;i<defaultGenFileRetryCount;i++) {
+            IndexInput genInput = null;
+            try {
+              genInput = directory.openInput(IndexFileNames.SEGMENTS_GEN);
+            } catch (FileNotFoundException e) {
+              message("segments.gen open: FileNotFoundException " + e);
+              break;
+            } catch (IOException e) {
+              message("segments.gen open: IOException " + e);
+            }
+  
+            if (genInput != null) {
               try {
-                genInput = directory.openInput(IndexFileNames.SEGMENTS_GEN);
-              } catch (FileNotFoundException e) {
-                message("segments.gen open: FileNotFoundException " + e);
-                break;
-              } catch (IOException e) {
-                message("segments.gen open: IOException " + e);
-              }
-
-              if (genInput != null) {
-                try {
-                  int version = genInput.readInt();
-                  if (version == FORMAT_LOCKLESS) {
-                    long gen0 = genInput.readLong();
-                    long gen1 = genInput.readLong();
-                    message("fallback check: " + gen0 + "; " + gen1);
-                    if (gen0 == gen1) {
-                      // The file is consistent.
-                      genB = gen0;
-                      break;
-                    }
+                int version = genInput.readInt();
+                if (version == FORMAT_LOCKLESS) {
+                  long gen0 = genInput.readLong();
+                  long gen1 = genInput.readLong();
+                  message("fallback check: " + gen0 + "; " + gen1);
+                  if (gen0 == gen1) {
+                    // The file is consistent.
+                    genB = gen0;
+                    break;
                   }
-                } catch (IOException err2) {
-                  // will retry
-                } finally {
-                  genInput.close();
                 }
+              } catch (IOException err2) {
+                // will retry
+              } finally {
+                genInput.close();
               }
-              try {
-                Thread.sleep(defaultGenFileRetryPauseMsec);
-              } catch (InterruptedException ie) {
-                // In 3.0 we will change this to throw
-                // InterruptedException instead
-                Thread.currentThread().interrupt();
-                throw new RuntimeException(ie);
-              }
+            }
+            try {
+              Thread.sleep(defaultGenFileRetryPauseMsec);
+            } catch (InterruptedException ie) {
+              // In 3.0 we will change this to throw
+              // InterruptedException instead
+              Thread.currentThread().interrupt();
+              throw new RuntimeException(ie);
             }
           }
 



Mime
View raw message