Merge pull request #54 from surlemur/master
log exceptions thrown in async tasks
This commit is contained in:
@@ -4,6 +4,8 @@ package io.socket.thread;
|
|||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,6 +13,8 @@ import java.util.concurrent.ThreadFactory;
|
|||||||
*/
|
*/
|
||||||
public class EventThread extends Thread {
|
public class EventThread extends Thread {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(EventThread.class.getName());
|
||||||
|
|
||||||
private static final ThreadFactory THREAD_FACTORY = new ThreadFactory() {
|
private static final ThreadFactory THREAD_FACTORY = new ThreadFactory() {
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable) {
|
public Thread newThread(Runnable runnable) {
|
||||||
@@ -73,6 +77,9 @@ public class EventThread extends Thread {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
task.run();
|
task.run();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
logger.log(Level.SEVERE, "Task threw exception", t);
|
||||||
|
throw t;
|
||||||
} finally {
|
} finally {
|
||||||
synchronized (EventThread.class) {
|
synchronized (EventThread.class) {
|
||||||
counter--;
|
counter--;
|
||||||
|
|||||||
Reference in New Issue
Block a user