lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r788319 - in /lucene/java/trunk: ./ src/java/org/apache/lucene/index/ src/java/org/apache/lucene/store/ src/test/org/apache/lucene/index/
Date Thu, 25 Jun 2009 10:55:37 GMT
Author: mikemccand
Date: Thu Jun 25 10:55:36 2009
New Revision: 788319

URL: http://svn.apache.org/viewvc?rev=788319&view=rev
Log:
LUCENE-1715: null out a few things on closing SegmentReader; remove finalizers from Lucene's
core

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/trunk/src/java/org/apache/lucene/store/NativeFSLockFactory.java
    lucene/java/trunk/src/java/org/apache/lucene/store/SimpleFSDirectory.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=788319&r1=788318&r2=788319&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Thu Jun 25 10:55:36 2009
@@ -116,7 +116,18 @@
     deleted. You can call IndexReader.isDeleted(n) prior to calling document(n).
     (Shai Erera via Mike McCandless)
 
-API Changes
+ 8. LUCENE-1715: Finalizers have been removed from the 4 core classes
+    that still had them, since they will cause GC to take longer, thus
+    tying up memory for longer, and at best they mask buggy app code.
+    DirectoryReader (returned from IndexReader.open) & IndexWriter
+    previously released the write lock during finalize.
+    SimpleFSDirectory.FSIndexInput closed the descriptor in its
+    finalizer, and NativeFSLock released the lock.  It's possible
+    applications will be affected by this, but only if the application
+    is failing to close reader/writers.  (Brian Groose via Mike
+    McCandless)
+
+ API Changes
 
 1. LUCENE-1419: Add expert API to set custom indexing chain. This API is 
    package-protected for now, so we don't have to officially support it.

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java?rev=788319&r1=788318&r2=788319&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java Thu Jun 25 10:55:36
2009
@@ -794,6 +794,7 @@
 
   protected synchronized void doClose() throws IOException {
     IOException ioe = null;
+    normsCache = null;
     for (int i = 0; i < subReaders.length; i++) {
       // try to close each reader, even if an exception is thrown
       try {

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java?rev=788319&r1=788318&r2=788319&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java Thu Jun 25 10:55:36
2009
@@ -745,6 +745,8 @@
     
     if (deletedDocs != null) {
       deletedDocsRef.decRef();
+      // null so if an app hangs on to us we still free most ram
+      deletedDocs = null;
     }
 
     Iterator it = norms.values().iterator();
@@ -757,6 +759,8 @@
       // close everything, nothing is shared anymore with other readers
       if (tis != null) {
         tis.close();
+        // null so if an app hangs on to us we still free most ram
+        tis = null;
       }
       
       if (freqStream != null)

Modified: lucene/java/trunk/src/java/org/apache/lucene/store/NativeFSLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/store/NativeFSLockFactory.java?rev=788319&r1=788318&r2=788319&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/store/NativeFSLockFactory.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/store/NativeFSLockFactory.java Thu Jun 25
10:55:36 2009
@@ -319,14 +319,4 @@
   public String toString() {
     return "NativeFSLock@" + path;
   }
-
-  public void finalize() throws Throwable {
-    try {
-      if (isLocked()) {
-        release();
-      }
-    } finally {
-      super.finalize();
-    }
-  }
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/store/SimpleFSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/store/SimpleFSDirectory.java?rev=788319&r1=788318&r2=788319&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/store/SimpleFSDirectory.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/store/SimpleFSDirectory.java Thu Jun 25 10:55:36
2009
@@ -85,14 +85,6 @@
           super.close();
         }
       }
-  
-      protected void finalize() throws Throwable {
-        try {
-          close();
-        } finally {
-          super.finalize();
-        }
-      }
     }
   
     protected final Descriptor file;

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java?rev=788319&r1=788318&r2=788319&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReaderReopen.java Thu Jun
25 10:55:36 2009
@@ -45,6 +45,7 @@
 import org.apache.lucene.store.MockRAMDirectory;
 import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.BitVector;
 
 public class TestIndexReaderReopen extends LuceneTestCase {
     
@@ -1214,10 +1215,11 @@
 
     // At this point they share the same BitVector
     assertTrue(sr1.deletedDocs==sr2.deletedDocs);
+    final BitVector delDocs = sr1.deletedDocs;
     r1.close();
 
     r2.deleteDocument(0);
-    assertTrue(sr1.deletedDocs==sr2.deletedDocs);
+    assertTrue(delDocs==sr2.deletedDocs);
     r2.close();
     dir.close();
   }



Mime
View raw message