log exceptions trapped by FT's

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@759739 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2009-03-29 18:18:35 +00:00
parent d85921934a
commit d24be7d5e7
1 changed files with 19 additions and 12 deletions

View File

@ -57,6 +57,23 @@ public final class DebuggableThreadPoolExecutor extends ThreadPoolExecutor
public void afterExecute(Runnable r, Throwable t)
{
super.afterExecute(r,t);
if (r instanceof FutureTask) {
assert t == null;
try
{
((FutureTask)r).get();
}
catch (InterruptedException e)
{
throw new RuntimeException(e);
}
catch (ExecutionException e)
{
t = e;
}
}
if ( t != null )
{
Context ctx = ThreadLocalContext.get();
@ -66,20 +83,10 @@ public final class DebuggableThreadPoolExecutor extends ThreadPoolExecutor
if ( object != null )
{
logger_.info("**** In afterExecute() " + t.getClass().getName() + " occured while working with " + object + " ****");
}
else
{
logger_.info("**** In afterExecute() " + t.getClass().getName() + " occured ****");
logger_.error("In afterExecute() " + t.getClass().getName() + " occured while working with " + object);
}
}
Throwable cause = t.getCause();
if ( cause != null )
{
logger_.info( LogUtil.throwableToString(cause) );
}
logger_.info( LogUtil.throwableToString(t) );
logger_.error("Error in ThreadPoolExecutor", t);
}
}
}