File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
sentry/src/main/java/io/sentry Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change 44import java .util .concurrent .Callable ;
55import java .util .concurrent .CancellationException ;
66import java .util .concurrent .Future ;
7+ import java .util .concurrent .RejectedExecutionException ;
78import java .util .concurrent .ScheduledThreadPoolExecutor ;
89import java .util .concurrent .ThreadFactory ;
910import java .util .concurrent .TimeUnit ;
@@ -123,17 +124,18 @@ public boolean isClosed() {
123124 public void prewarm () {
124125 executorService .submit (
125126 () -> {
126- // schedule a bunch of dummy runnables in the future that will never execute to trigger
127- // queue
128- // growth and then clear the queue up
129- for (int i = 0 ; i < INITIAL_QUEUE_SIZE ; i ++) {
130- executorService .schedule (dummyRunnable , Long .MAX_VALUE , TimeUnit .DAYS );
127+ try {
128+ // schedule a bunch of dummy runnables in the future that will never execute to trigger
129+ // queue growth and then purge the queue
130+ for (int i = 0 ; i < INITIAL_QUEUE_SIZE ; i ++) {
131+ final Future <?> future = executorService .schedule (dummyRunnable , 365L , TimeUnit .DAYS );
132+ future .cancel (true );
133+ }
134+ executorService .purge ();
135+ } catch (RejectedExecutionException ignored ) {
136+ // ignore
131137 }
132138 });
133- executorService .submit (
134- () -> {
135- executorService .getQueue ().clear ();
136- });
137139 }
138140
139141 private static final class SentryExecutorServiceThreadFactory implements ThreadFactory {
You can’t perform that action at this time.
0 commit comments