|
|
@ -55,25 +55,45 @@ public class ThreadPoolConfig
|
|
|
|
protected ScheduledExecutorService scheduledExecutorService()
|
|
|
|
protected ScheduledExecutorService scheduledExecutorService()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return new ScheduledThreadPoolExecutor(corePoolSize,
|
|
|
|
return new ScheduledThreadPoolExecutor(corePoolSize,
|
|
|
|
new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build()) {
|
|
|
|
new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build())
|
|
|
|
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void afterExecute(Runnable r, Throwable t) {
|
|
|
|
protected void afterExecute(Runnable r, Throwable t)
|
|
|
|
|
|
|
|
{
|
|
|
|
super.afterExecute(r, t);
|
|
|
|
super.afterExecute(r, t);
|
|
|
|
if (t == null && r instanceof Future<?>) {
|
|
|
|
printException(r, t);
|
|
|
|
try {
|
|
|
|
}
|
|
|
|
Object result = ((Future<?>) r).get();
|
|
|
|
};
|
|
|
|
} catch (CancellationException ce) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void printException(Runnable r, Throwable t)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (t == null && r instanceof Future<?>)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Future<?> future = (Future<?>) r;
|
|
|
|
|
|
|
|
if (future.isDone())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
future.get();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (CancellationException ce)
|
|
|
|
|
|
|
|
{
|
|
|
|
t = ce;
|
|
|
|
t = ce;
|
|
|
|
} catch (ExecutionException ee) {
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (ExecutionException ee)
|
|
|
|
|
|
|
|
{
|
|
|
|
t = ee.getCause();
|
|
|
|
t = ee.getCause();
|
|
|
|
} catch (InterruptedException ie) {
|
|
|
|
|
|
|
|
Thread.currentThread().interrupt(); // ignore/reset
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (InterruptedException ie)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Thread.currentThread().interrupt();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(t != null) {
|
|
|
|
|
|
|
|
log.error(t.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log.error(t.getMessage(), t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|