mirror of https://github.com/apache/lucene.git
SOLR-7381: Uncaught exceptions thrown by tasks in the pool are logged along with submitter's stack trace
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1674593 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
04f870c172
commit
e699256bbb
|
@ -158,6 +158,7 @@ Other Changes
|
|||
Executors#newFixedThreadPool, #newSingleThreadExecutor, #newCachedThreadPool as well as
|
||||
ThreadPoolExecutor directly is now forbidden in Solr. MDC keys are now exposed in thread
|
||||
names automatically so that a thread dump can give hints on what the thread was doing.
|
||||
Uncaught exceptions thrown by tasks in the pool are logged along with submitter's stack trace.
|
||||
(shalin)
|
||||
|
||||
* SOLR-7384: Fix spurious failures in FullSolrCloudDistribCmdsTest. (shalin)
|
||||
|
|
|
@ -130,6 +130,7 @@ public class ExecutorUtil {
|
|||
String ctxStr = submitterContext != null && !submitterContext.isEmpty() ?
|
||||
submitterContext.toString().replace("/", "//") : "";
|
||||
final String submitterContextStr = ctxStr.length() <= MAX_THREAD_NAME_LEN ? ctxStr : ctxStr.substring(0, MAX_THREAD_NAME_LEN);
|
||||
final Exception submitterStackTrace = new Exception("Submitter stack trace");
|
||||
super.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -144,8 +145,14 @@ public class ExecutorUtil {
|
|||
}
|
||||
try {
|
||||
command.run();
|
||||
} catch (Throwable t) {
|
||||
if (t instanceof OutOfMemoryError) {
|
||||
throw t;
|
||||
}
|
||||
log.error("Uncaught exception {} thrown by thread: {}", t, currentThread.getName(), submitterStackTrace);
|
||||
throw t;
|
||||
} finally {
|
||||
if (threadContext != null) {
|
||||
if (threadContext != null && !threadContext.isEmpty()) {
|
||||
MDC.setContextMap(threadContext);
|
||||
} else {
|
||||
MDC.clear();
|
||||
|
|
Loading…
Reference in New Issue