lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r678716 - in /lucene/java/trunk/src/java/org/apache/lucene/index: IndexReader.java SegmentReader.java
Date Tue, 22 Jul 2008 11:14:37 GMT
Author: mikemccand
Date: Tue Jul 22 04:14:36 2008
New Revision: 678716

URL: http://svn.apache.org/viewvc?rev=678716&view=rev
Log:
LUCENE-1339: make IndexReader incRef and decRef expert public methods

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java?rev=678716&r1=678715&r2=678716&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexReader.java Tue Jul 22 04:14:36
2008
@@ -102,23 +102,38 @@
   }
   
   /**
-   * Increments the refCount of this IndexReader instance. RefCounts are used to determine
-   * when a reader can be closed safely, i. e. as soon as no other IndexReader is referencing
-   * it anymore.
+   * Expert: increments the refCount of this IndexReader
+   * instance.  RefCounts are used to determine when a
+   * reader can be closed safely, i.e. as soon as there are
+   * no more references.  Be sure to always call a
+   * corresponding {@link #decRef}, in a finally clause;
+   * otherwise the reader may never be closed.  Note that
+   * {@link #close} simply calls decRef(), which means that
+   * the IndexReader will not really be closed until {@link
+   * #decRef} has been called for all outstanding
+   * references.
+   *
+   * @see #decRef
    */
-  protected synchronized void incRef() {
+  public synchronized void incRef() {
     assert refCount > 0;
+    ensureOpen();
     refCount++;
   }
 
   /**
-   * Decreases the refCount of this IndexReader instance. If the refCount drops
-   * to 0, then pending changes are committed to the index and this reader is closed.
+   * Expert: decreases the refCount of this IndexReader
+   * instance.  If the refCount drops to 0, then pending
+   * changes (if any) are committed to the index and this
+   * reader is closed.
    * 
    * @throws IOException in case an IOException occurs in commit() or doClose()
+   *
+   * @see #incRef
    */
-  protected synchronized void decRef() throws IOException {
+  public synchronized void decRef() throws IOException {
     assert refCount > 0;
+    ensureOpen();
     if (refCount == 1) {
       commit();
       doClose();

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=678716&r1=678715&r2=678716&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 Tue Jul 22 04:14:36
2008
@@ -138,7 +138,7 @@
    * Increments the RC of this reader, as well as
    * of all norms this reader is using
    */
-  protected synchronized void incRef() {
+  public synchronized void incRef() {
     super.incRef();
     Iterator it = norms.values().iterator();
     while (it.hasNext()) {
@@ -157,7 +157,7 @@
     super.incRef();
   }
 
-  protected synchronized void decRef() throws IOException {
+  public synchronized void decRef() throws IOException {
     super.decRef();
     Iterator it = norms.values().iterator();
     while (it.hasNext()) {



Mime
View raw message