You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2013/11/05 17:31:34 UTC
svn commit: r1539050 - in
/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene:
ConsistencyCheck.java ConsistencyCheckError.java
Author: jukka
Date: Tue Nov 5 16:31:34 2013
New Revision: 1539050
URL: http://svn.apache.org/r1539050
Log:
JCR-3691: Search index consistency check logs unnecessary warnings for repairable errors
Don't throw away exception stack traces
Modified:
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheckError.java
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java?rev=1539050&r1=1539049&r2=1539050&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java Tue Nov 5 16:31:34 2013
@@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.core.query.lucene;
+import org.apache.commons.io.IOExceptionWithCause;
import org.apache.jackrabbit.core.HierarchyManager;
import org.apache.jackrabbit.core.RepositoryImpl;
import org.apache.jackrabbit.core.cluster.ClusterException;
@@ -174,11 +175,10 @@ public class ConsistencyCheck {
} catch (Exception e) {
if (ignoreFailure) {
log.warn("Exception while repairing: " + error, e);
- } else {
- if (!(e instanceof IOException)) {
- e = new IOException(e.getMessage());
- }
+ } else if (e instanceof IOException) {
throw (IOException) e;
+ } else {
+ throw new IOExceptionWithCause(e);
}
}
}
@@ -482,23 +482,17 @@ public class ConsistencyCheck {
/**
* Repairs the missing node by indexing the missing ancestors.
- * @throws IOException if an error occurs while repairing.
+ * @throws Exception if an error occurs while repairing.
*/
- public void repair() throws IOException {
+ public void repair() throws Exception {
NodeId ancestorId = parentId;
while (ancestorId != null && nodeIds.containsKey(ancestorId) && nodeIds.get(ancestorId)) {
- try {
- NodeState n = (NodeState) stateMgr.getItemState(ancestorId);
- log.info("Repairing missing node " + getPath(n) + " (" + ancestorId + ")");
- Document d = index.createDocument(n);
- index.addDocument(d);
- nodeIds.put(n.getNodeId(), Boolean.TRUE);
- ancestorId = n.getParentId();
- } catch (ItemStateException e) {
- throw new IOException(e.toString());
- } catch (RepositoryException e) {
- throw new IOException(e.toString());
- }
+ NodeState n = (NodeState) stateMgr.getItemState(ancestorId);
+ log.info("Repairing missing node " + getPath(n) + " (" + ancestorId + ")");
+ Document d = index.createDocument(n);
+ index.addDocument(d);
+ nodeIds.put(n.getNodeId(), Boolean.TRUE);
+ ancestorId = n.getParentId();
}
}
@@ -543,7 +537,7 @@ public class ConsistencyCheck {
/**
* No operation.
*/
- public void repair() throws IOException {
+ public void repair() {
log.warn("Unknown parent for " + id + " cannot be repaired");
}
@@ -585,7 +579,7 @@ public class ConsistencyCheck {
* Reindex node.
*/
@Override
- void repair() throws IOException {
+ void repair() throws Exception {
index.removeAllDocuments(id);
try {
NodeState node = (NodeState) stateMgr.getItemState(id);
@@ -595,10 +589,6 @@ public class ConsistencyCheck {
nodeIds.put(node.getNodeId(), Boolean.TRUE);
} catch (NoSuchItemStateException e) {
log.info("Not re-indexing node with wrong parent because node no longer exists");
- } catch (ItemStateException e) {
- throw new IOException(e.toString());
- } catch (RepositoryException e) {
- throw new IOException(e.toString());
}
}
@@ -642,7 +632,7 @@ public class ConsistencyCheck {
* re-index the node.
* @throws IOException if an error occurs while repairing.
*/
- public void repair() throws IOException {
+ public void repair() throws Exception {
// first remove all occurrences
index.removeAllDocuments(id);
// then re-index the node
@@ -654,10 +644,6 @@ public class ConsistencyCheck {
nodeIds.put(node.getNodeId(), Boolean.TRUE);
} catch (NoSuchItemStateException e) {
log.info("Not re-indexing node with multiple occurrences because node no longer exists");
- } catch (ItemStateException e) {
- throw new IOException(e.toString());
- } catch (RepositoryException e) {
- throw new IOException(e.toString());
}
}
@@ -719,19 +705,15 @@ public class ConsistencyCheck {
}
@Override
- void repair() throws IOException {
+ void repair() throws Exception {
try {
NodeState nodeState = (NodeState) stateMgr.getItemState(id);
log.info("Adding missing node to index: " + getPath(nodeState));
final Iterator<NodeId> remove = Collections.<NodeId>emptyList().iterator();
final Iterator<NodeState> add = Collections.singletonList(nodeState).iterator();
handler.updateNodes(remove, add);
- } catch (RepositoryException e) {
- throw new IOException(e.toString());
} catch (NoSuchItemStateException e) {
log.info("Not adding missing node because node no longer exists");
- } catch (ItemStateException e) {
- throw new IOException(e.toString());
}
}
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheckError.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheckError.java?rev=1539050&r1=1539049&r2=1539050&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheckError.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheckError.java Tue Nov 5 16:31:34 2013
@@ -59,9 +59,9 @@ public abstract class ConsistencyCheckEr
/**
* Executes the repair operation.
- * @throws IOException if an error occurs while repairing.
+ * @throws Exception if an error occurs while repairing.
*/
- abstract void repair() throws IOException;
+ abstract void repair() throws Exception;
/**
* Double check the error. Used to rule out false positives in live environments.