Skip to content

Commit

Permalink
revert 812227, which introduced a regression to DebuggableScheduledTh…
Browse files Browse the repository at this point in the history
…readPoolExecutor. patch by jbellis for CASSANDRA-455.

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/branches/cassandra-0.4@819004 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
jbellis committed Sep 25, 2009
1 parent 68b462d commit 3f31d85
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 18 deletions.
Expand Up @@ -46,11 +46,29 @@ public DebuggableScheduledThreadPoolExecutor(int threads,
public void afterExecute(Runnable r, Throwable t)
{
super.afterExecute(r,t);

DebuggableThreadPoolExecutor.logFutureExceptions(r);
if (t != null)
{
logger_.error("Error in ThreadPoolExecutor", t);
if ( t != null )
{
Context ctx = ThreadLocalContext.get();
if ( ctx != null )
{
Object object = ctx.get(r.getClass().getName());

if ( object != null )
{
logger_.info("**** In afterExecute() " + t.getClass().getName() + " occured while working with " + object + " ****");
}
else
{
logger_.info("**** In afterExecute() " + t.getClass().getName() + " occured ****");
}
}

Throwable cause = t.getCause();
if ( cause != null )
{
logger_.info( LogUtil.throwableToString(cause) );
}
logger_.info( LogUtil.throwableToString(t) );
}
}
}
Expand Up @@ -79,29 +79,35 @@ public void afterExecute(Runnable r, Throwable t)
{
super.afterExecute(r,t);

logFutureExceptions(r);
if (t != null)
{
logger_.error("Error in ThreadPoolExecutor", t);
}
}

public static void logFutureExceptions(Runnable r)
{
if (r instanceof FutureTask)
{
if (r instanceof FutureTask) {
assert t == null;
try
{
((FutureTask)r).get();
}
catch (InterruptedException e)
{
throw new AssertionError(e);
throw new RuntimeException(e);
}
catch (ExecutionException e)
{
logger_.error("Error in executor futuretask", e);
t = e;
}
}

if ( t != null )
{
Context ctx = ThreadLocalContext.get();
if ( ctx != null )
{
Object object = ctx.get(r.getClass().getName());

if ( object != null )
{
logger_.error("In afterExecute() " + t.getClass().getName() + " occured while working with " + object);
}
}
logger_.error("Error in ThreadPoolExecutor", t);
}
}
}

0 comments on commit 3f31d85

Please sign in to comment.