jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r650521 - in /jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene: MultiIndex.java Recovery.java
Date Tue, 22 Apr 2008 13:42:43 GMT
Author: jukka
Date: Tue Apr 22 06:42:34 2008
New Revision: 650521

URL: http://svn.apache.org/viewvc?rev=650521&view=rev
Log:
1.4: Merged revision 647796 (JCR-1536)

Modified:
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Recovery.java

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java?rev=650521&r1=650520&r2=650521&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
Tue Apr 22 06:42:34 2008
@@ -434,10 +434,7 @@
             synchronized (updateMonitor) {
                 updateInProgress = false;
                 updateMonitor.notifyAll();
-                if (multiReader != null) {
-                    multiReader.close();
-                    multiReader = null;
-                }
+                closeMultiReader();
             }
         }
     }
@@ -500,10 +497,7 @@
             synchronized (updateMonitor) {
                 updateInProgress = false;
                 updateMonitor.notifyAll();
-                if (multiReader != null) {
-                    multiReader.close();
-                    multiReader = null;
-                }
+                closeMultiReader();
             }
         }
         return num;
@@ -671,10 +665,7 @@
                 synchronized (updateMonitor) {
                     updateInProgress = false;
                     updateMonitor.notifyAll();
-                    if (multiReader != null) {
-                        multiReader.close();
-                        multiReader = null;
-                    }
+                    closeMultiReader();
                 }
             }
         }
@@ -750,13 +741,10 @@
             flushTask.cancel();
 
             // commit / close indexes
-            if (multiReader != null) {
-                try {
-                    multiReader.close();
-                } catch (IOException e) {
-                    log.error("Exception while closing search index.", e);
-                }
-                multiReader = null;
+            try {
+                closeMultiReader();
+            } catch (IOException e) {
+                log.error("Exception while closing search index.", e);
             }
             try {
                 flush();
@@ -897,6 +885,28 @@
         attemptDelete();
     }
 
+    /**
+     * Closes the {@link #multiReader} and sets it <code>null</code>. If the
+     * reader is already <code>null</code> this method does nothing. When this
+     * method returns {@link #multiReader} is guaranteed to be <code>null</code>
+     * even if an exception is thrown.
+     * <p/>
+     * Please note that this method does not take care of any synchronization.
+     * A caller must ensure that it is the only thread operating on this multi
+     * index, or that it holds the {@link #updateMonitor}.
+     *
+     * @throws IOException if an error occurs while closing the reader.
+     */
+    void closeMultiReader() throws IOException {
+        if (multiReader != null) {
+            try {
+                multiReader.close();
+            } finally {
+                multiReader = null;
+            }
+        }
+    }
+
     //-------------------------< internal >-------------------------------------
 
     private void scheduleFlushTask() {
@@ -1114,10 +1124,7 @@
                         synchronized (updateMonitor) {
                             updateInProgress = false;
                             updateMonitor.notifyAll();
-                            if (multiReader != null) {
-                                multiReader.close();
-                                multiReader = null;
-                            }
+                            closeMultiReader();
                         }
                     }
                 }

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Recovery.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Recovery.java?rev=650521&r1=650520&r2=650521&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Recovery.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Recovery.java
Tue Apr 22 06:42:34 2008
@@ -170,5 +170,6 @@
 
         // now we are consistent again -> flush
         index.flush();
+        index.closeMultiReader();
     }
 }



Mime
View raw message