Skip to content

Apache Lucene open-source search software

SOLR-4915: The root cause should be returned to the user when a SolrCore create call fails.

Mark Robert Milleraf2128c683ca
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index feb23fbbfd2..682b793f5aa 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -136,6 +136,9 @@ Bug Fixes
if a SQLException is thrown while initializing a connection, such as in setAutoCommit(), the
connection will not be closed. (Chris Eldredge via shalin)
+* SOLR-4915: The root cause should be returned to the user when a SolrCore create call fails.
+ (Mark Miller)
+
Other Changes
----------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
index 27b57365fc0..6b0f1937a9e 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
@@ -524,9 +524,24 @@ public class CoreAdminHandler extends RequestHandlerBase {
SolrException.log(log, null, e);
}
}
+
+ Throwable tc = ex;
+ Throwable c = null;
+ do {
+ tc = tc.getCause();
+ if (tc != null) {
+ c = tc;
+ }
+ } while (tc != null);
+
+ String rootMsg = "";
+ if (c != null) {
+ rootMsg = " Caused by: " + c.getMessage();
+ }
+
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Error CREATEing SolrCore '" + name + "': " +
- ex.getMessage(), ex);
+ ex.getMessage() + rootMsg, ex);
}
}