Index: CHANGES.txt =================================================================== --- CHANGES.txt (revision 787830) +++ CHANGES.txt (working copy) @@ -116,8 +116,19 @@ 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. Yet, it will give us the possibility to try out different consumers Index: src/test/org/apache/lucene/index/TestIndexReaderReopen.java =================================================================== --- src/test/org/apache/lucene/index/TestIndexReaderReopen.java (revision 787830) +++ src/test/org/apache/lucene/index/TestIndexReaderReopen.java (working copy) @@ -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(); } Index: src/java/org/apache/lucene/index/SegmentReader.java =================================================================== --- src/java/org/apache/lucene/index/SegmentReader.java (revision 787830) +++ src/java/org/apache/lucene/index/SegmentReader.java (working copy) @@ -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) Index: src/java/org/apache/lucene/index/DirectoryReader.java =================================================================== --- src/java/org/apache/lucene/index/DirectoryReader.java (revision 787830) +++ src/java/org/apache/lucene/index/DirectoryReader.java (working copy) @@ -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 { Index: src/java/org/apache/lucene/store/SimpleFSDirectory.java =================================================================== --- src/java/org/apache/lucene/store/SimpleFSDirectory.java (revision 787830) +++ src/java/org/apache/lucene/store/SimpleFSDirectory.java (working copy) @@ -85,14 +85,6 @@ super.close(); } } - - protected void finalize() throws Throwable { - try { - close(); - } finally { - super.finalize(); - } - } } protected final Descriptor file; Index: src/java/org/apache/lucene/store/NativeFSLockFactory.java =================================================================== --- src/java/org/apache/lucene/store/NativeFSLockFactory.java (revision 787830) +++ src/java/org/apache/lucene/store/NativeFSLockFactory.java (working copy) @@ -319,14 +319,4 @@ public String toString() { return "NativeFSLock@" + path; } - - public void finalize() throws Throwable { - try { - if (isLocked()) { - release(); - } - } finally { - super.finalize(); - } - } }