File tree Expand file tree Collapse file tree
examples/simple/src/main/java/com/bugsnag/example/simple
src/main/java/com/bugsnag/delivery Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,8 +61,5 @@ public void run() {
6161 throw new RuntimeException ("Unhandled exception" );
6262 }
6363 }).start ();
64-
65- // Exit to run the shutdown hooks
66- System .exit (0 );
6764 }
6865}
Original file line number Diff line number Diff line change 77
88import java .net .Proxy ;
99import java .util .concurrent .ExecutorService ;
10- import java .util .concurrent .Executors ;
10+ import java .util .concurrent .LinkedBlockingQueue ;
11+ import java .util .concurrent .ThreadPoolExecutor ;
1112import java .util .concurrent .TimeUnit ;
1213
1314public class AsyncHttpDelivery implements HttpDelivery {
1415 private static final Logger logger = LoggerFactory .getLogger (AsyncHttpDelivery .class );
1516 private static final int SHUTDOWN_TIMEOUT = 5000 ;
1617
17- protected HttpDelivery baseDelivery = new SyncHttpDelivery ();
18- protected ExecutorService executorService = Executors .newSingleThreadExecutor ();
18+ private HttpDelivery baseDelivery = new SyncHttpDelivery ();
19+
20+ // Create an exector service which keeps idle threads alive for a maximum of SHUTDOWN_TIMEOUT.
21+ // This should avoid blocking an application that doesn't call shutdown from exiting.
22+ private ExecutorService executorService =
23+ new ThreadPoolExecutor (0 , 1 ,
24+ SHUTDOWN_TIMEOUT , TimeUnit .MILLISECONDS ,
25+ new LinkedBlockingQueue <Runnable >());
26+
1927 private boolean shuttingDown = false ;
2028
2129 /**
You can’t perform that action at this time.
0 commit comments