Apache Solr open-source search software
LUCENE-5987: don't double-wrap AbortingException
Michael McCandless8c806353285b
diff --git a/lucene/core/src/java/org/apache/lucene/index/AbortingException.java b/lucene/core/src/java/org/apache/lucene/index/AbortingException.javaindex 2895f6870f7..1722980a473 100644--- a/lucene/core/src/java/org/apache/lucene/index/AbortingException.java+++ b/lucene/core/src/java/org/apache/lucene/index/AbortingException.java@@ -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);+ }}}diff --git a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.javaindex b7a839c1b7e..57deefb0bd5 100644--- a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java+++ b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java@@ -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);}}diff --git a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.javaindex 6f4d5d871c0..053fbcaa7e5 100644--- a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java+++ b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java@@ -456,7 +456,7 @@ class DocumentsWriterPerThread {return fs;} catch (Throwable th) {abort();- throw new AbortingException(th);+ throw AbortingException.wrap(th);}}