Apache Solr open-source search software
Add correct exception logging in the ExecutorUtil (#2384)
Houston Putman07606c72818a
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java b/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.javaindex c97658efebd..b5bd42257d7 100644--- a/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java+++ b/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java@@ -314,15 +314,19 @@ public class ExecutorUtil {if (t instanceof OutOfMemoryError) {throw t;}- if (enableSubmitterStackTrace) {- log.error(- "Uncaught exception {} thrown by thread: {}",- t,- currentThread.getName(),- submitterStackTrace);- } else {- log.error("Uncaught exception {} thrown by thread: {}", t, currentThread.getName());+ // Flip around the exception cause tree, because it is in reverse order+ Throwable baseCause = t;+ Throwable nextCause = submitterStackTrace;+ while (nextCause != null) {+ baseCause = new Exception(nextCause.getMessage(), baseCause);+ baseCause.setStackTrace(nextCause.getStackTrace());+ nextCause = nextCause.getCause();}+ log.error(+ "Uncaught exception {} thrown by thread: {}",+ t,+ currentThread.getName(),+ baseCause);throw t;} finally {isServerPool.remove();