You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2015/04/19 05:49:03 UTC
svn commit: r1674594 - in /lucene/dev/branches/branch_5x: ./ solr/
solr/CHANGES.txt solr/solrj/
solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
Author: shalin
Date: Sun Apr 19 03:49:02 2015
New Revision: 1674594
URL: http://svn.apache.org/r1674594
Log:
SOLR-7381: Uncaught exceptions thrown by tasks in the pool are logged along with submitter's stack trace
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/solr/ (props changed)
lucene/dev/branches/branch_5x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_5x/solr/solrj/ (props changed)
lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1674594&r1=1674593&r2=1674594&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Sun Apr 19 03:49:02 2015
@@ -106,6 +106,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)
Modified: lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java?rev=1674594&r1=1674593&r2=1674594&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java (original)
+++ lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java Sun Apr 19 03:49:02 2015
@@ -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();