LUCENE-5987: don't double-wrap AbortingException

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1644072 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-12-09 14:59:30 +00:00
parent a5fc2765e4
commit 8c80635328
3 changed files with 16 additions and 7 deletions

View File

@ -21,7 +21,16 @@ package org.apache.lucene.index;
* lose previously indexed documents. When this happens, the {@link IndexWriter} is forcefully
* closed, using {@link IndexWriter#rollback}). */
class AbortingException extends Exception {
AbortingException(Throwable cause) {
private AbortingException(Throwable cause) {
super(cause);
assert cause instanceof AbortingException == false;
}
public static AbortingException wrap(Throwable t) {
if (t instanceof AbortingException) {
return (AbortingException) t;
} else {
return new AbortingException(t);
}
}
}

View File

@ -258,7 +258,7 @@ final class DefaultIndexingChain extends DocConsumer {
initStoredFieldsWriter();
storedFieldsWriter.startDocument();
} catch (Throwable th) {
throw new AbortingException(th);
throw AbortingException.wrap(th);
}
lastStoredDocID++;
}
@ -269,7 +269,7 @@ final class DefaultIndexingChain extends DocConsumer {
try {
storedFieldsWriter.finishDocument();
} catch (Throwable th) {
throw new AbortingException(th);
throw AbortingException.wrap(th);
}
}
@ -322,7 +322,7 @@ final class DefaultIndexingChain extends DocConsumer {
} catch (Throwable th) {
// Must abort, on the possibility that on-disk term
// vectors are now corrupt:
throw new AbortingException(th);
throw AbortingException.wrap(th);
}
// Add stored fields:
@ -344,7 +344,7 @@ final class DefaultIndexingChain extends DocConsumer {
storedFieldsWriter.writeField(fp.fieldInfo, field);
} catch (Throwable th) {
abort = true;
throw new AbortingException(th);
throw AbortingException.wrap(th);
}
}
@ -655,7 +655,7 @@ final class DefaultIndexingChain extends DocConsumer {
// Document will be deleted above:
throw new IllegalArgumentException(msg, e);
} catch (Throwable th) {
throw new AbortingException(th);
throw AbortingException.wrap(th);
}
}

View File

@ -456,7 +456,7 @@ class DocumentsWriterPerThread {
return fs;
} catch (Throwable th) {
abort();
throw new AbortingException(th);
throw AbortingException.wrap(th);
}
}