jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r647796 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene: MultiIndex.java Recovery.java
Date Mon, 14 Apr 2008 13:35:14 GMT
Author: mreutegg
Date: Mon Apr 14 06:35:08 2008
New Revision: 647796

URL: http://svn.apache.org/viewvc?rev=647796&view=rev
Log:
JCR-1536: "Index already present" exception when opening a restored repository

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

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java?rev=647796&r1=647795&r2=647796&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
Mon Apr 14 06:35:08 2008
@@ -444,10 +444,7 @@
             synchronized (updateMonitor) {
                 updateInProgress = false;
                 updateMonitor.notifyAll();
-                if (multiReader != null) {
-                    multiReader.close();
-                    multiReader = null;
-                }
+                closeMultiReader();
             }
         }
     }
@@ -510,10 +507,7 @@
             synchronized (updateMonitor) {
                 updateInProgress = false;
                 updateMonitor.notifyAll();
-                if (multiReader != null) {
-                    multiReader.close();
-                    multiReader = null;
-                }
+                closeMultiReader();
             }
         }
         return num;
@@ -682,10 +676,7 @@
                 synchronized (updateMonitor) {
                     updateInProgress = false;
                     updateMonitor.notifyAll();
-                    if (multiReader != null) {
-                        multiReader.close();
-                        multiReader = null;
-                    }
+                    closeMultiReader();
                 }
             }
         }
@@ -761,13 +752,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();
@@ -908,6 +896,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() {
@@ -1143,10 +1153,7 @@
                         synchronized (updateMonitor) {
                             updateInProgress = false;
                             updateMonitor.notifyAll();
-                            if (multiReader != null) {
-                                multiReader.close();
-                                multiReader = null;
-                            }
+                            closeMultiReader();
                         }
                     }
                 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Recovery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Recovery.java?rev=647796&r1=647795&r2=647796&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Recovery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Recovery.java
Mon Apr 14 06:35:08 2008
@@ -170,5 +170,6 @@
 
         // now we are consistent again -> flush
         index.flush();
+        index.closeMultiReader();
     }
 }



Mime
View raw message