This is an automated email from the ASF dual-hosted git repository.

houston pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 07606c72818 Add correct exception logging in the ExecutorUtil (#2384)
07606c72818 is described below

commit 07606c72818aa3f81c0dd4662fc9ee57dbba2070
Author: Houston Putman <[email protected]>
AuthorDate: Tue Apr 16 10:16:31 2024 -0400

    Add correct exception logging in the ExecutorUtil (#2384)
---
 .../org/apache/solr/common/util/ExecutorUtil.java    | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

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.java
index 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();

Reply via email to